public interface NetworkAddressManagerService
Modifier and Type | Field and Description |
---|---|
static int |
BIND_RETRIES_DEFAULT_VALUE
The default number of binds that a NetworkAddressManagerService
implementation should execute in case a port is already bound to (each
retry would be on a different port).
|
static java.lang.String |
BIND_RETRIES_PROPERTY_NAME
The name of the property containing number of binds that a
NetworkAddressManagerService implementation should execute in
case a port is already bound to (each retry would be on a different
port).
|
Modifier and Type | Method and Description |
---|---|
void |
addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
Adds new NetworkConfigurationChangeListener which will
be informed for network configuration changes.
|
java.net.DatagramSocket |
createDatagramSocket(java.net.InetAddress laddr,
int preferredPort,
int minPort,
int maxPort)
Creates a DatagramSocket and binds it to on the specified
localAddress and a port in the range specified by the
minPort and maxPort parameters.
|
org.ice4j.ice.Agent |
createIceAgent()
Creates and returns an ICE agent that a protocol could use for the
negotiation of media transport addresses.
|
org.ice4j.ice.IceMediaStream |
createIceStream(int numComponents,
int portBase,
java.lang.String streamName,
org.ice4j.ice.Agent agent)
Creates an IceMediaStrean and adds to it one or two
components, which also implies running the currently installed
harvesters.
|
org.ice4j.ice.IceMediaStream |
createIceStream(int rtpPort,
java.lang.String streamName,
org.ice4j.ice.Agent agent)
Creates an IceMediaStrean and adds to it an RTP and and RTCP
component, which also implies running the currently installed
harvesters so that they would.
|
org.ice4j.ice.harvest.StunCandidateHarvester |
discoverStunServer(java.lang.String domainName,
byte[] userName,
byte[] password)
Tries to discover a TURN or a STUN server for the specified
domainName.
|
byte[] |
getHardwareAddress(java.net.NetworkInterface iface)
Returns the hardware address (i.e.
|
java.net.InetAddress |
getLocalHost(java.net.InetAddress intendedDestination)
Returns an InetAddress instance that represents the localhost, and that
a socket can bind upon or distribute to peers as a contact address.
|
java.net.InetSocketAddress |
getPublicAddressFor(java.net.InetAddress intendedDestination,
int port)
Tries to obtain a mapped/public address for the specified port.
|
void |
removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
Remove NetworkConfigurationChangeListener.
|
static final int BIND_RETRIES_DEFAULT_VALUE
static final java.lang.String BIND_RETRIES_PROPERTY_NAME
java.net.InetAddress getLocalHost(java.net.InetAddress intendedDestination)
This method tries to make for the ambiguity in the implementation of the InetAddress.getLocalHost() method. (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4665037).
To put it briefly, the issue is about choosing a local source address to bind to or to distribute to peers. It is possible and even quite probable to expect that a machine may dispose with multiple addresses and each of them may be valid for a specific destination. Example cases include:
1) A dual stack IPv6/IPv4 box.
2) A double NIC box with a leg on the Internet and another one in a
private LAN
3) In the presence of a virtual interface over a VPN or a MobileIP(v6)
tunnel.
In all such cases a source local address needs to be chosen according to the intended destination and after consulting the local routing table.
intendedDestination
- the address of the destination that we'd like
to access through the local address that we are requesting.java.net.InetSocketAddress getPublicAddressFor(java.net.InetAddress intendedDestination, int port) throws java.io.IOException, java.net.BindException
intendedDestination
- the destination that we'd like to use this
address with.port
- the port whose mapping we are interested in.java.io.IOException
- if an error occurs while the underlying resolver lib
is using sockets.java.net.BindException
- if the port is already in use.byte[] getHardwareAddress(java.net.NetworkInterface iface)
iface
- the NetworkInterfacejava.net.DatagramSocket createDatagramSocket(java.net.InetAddress laddr, int preferredPort, int minPort, int maxPort) throws java.lang.IllegalArgumentException, java.io.IOException, java.net.BindException
laddr
- the address that we'd like to bind the socket on.preferredPort
- the port number that we should try to bind to first.minPort
- the port number where we should first try to bind before
moving to the next one (i.e. minPort + 1)maxPort
- the maximum port number where we should try binding
before giving up and throwinG an exception.java.lang.IllegalArgumentException
- if either minPort or
maxPort is not a valid port number.java.io.IOException
- if an error occurs while the underlying resolver lib
is using sockets.java.net.BindException
- if we couldn't find a free port between
minPort and maxPort before reaching the maximum allowed
number of retries.void addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
listener
- the listener.void removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
listener
- the listener.org.ice4j.ice.Agent createIceAgent()
org.ice4j.ice.harvest.StunCandidateHarvester discoverStunServer(java.lang.String domainName, byte[] userName, byte[] password)
domainName
- the domain name that we are trying to discover a
TURN server for.userName
- the name of the user we'd like to use when connecting to
a TURN server (we won't be using credentials in case we only have a STUN
server).password
- the password that we'd like to try when connecting to
a TURN server (we won't be using credentials in case we only have a STUN
server).StunCandidateHarvester
corresponding to the TURN or
STUN server we discovered or null if there were no such records
for the specified domainNameorg.ice4j.ice.IceMediaStream createIceStream(int rtpPort, java.lang.String streamName, org.ice4j.ice.Agent agent) throws java.lang.IllegalArgumentException, java.io.IOException, java.net.BindException
rtpPort
- the port that we should try to bind the RTP component on
(the RTCP one would automatically go to rtpPort + 1)streamName
- the name of the stream to createagent
- the Agent that should create the stream.java.lang.IllegalArgumentException
- if rtpPort is not a valid port
number.java.io.IOException
- if an error occurs while the underlying resolver
is using sockets.java.net.BindException
- if we couldn't find a free port between within the
default number of retries.org.ice4j.ice.IceMediaStream createIceStream(int numComponents, int portBase, java.lang.String streamName, org.ice4j.ice.Agent agent) throws java.lang.IllegalArgumentException, java.io.IOException, java.net.BindException
portBase
- the port that we should try to bind first component on
(the second one would automatically go to portBase + 1)streamName
- the name of the stream to createagent
- the Agent that should create the stream.java.lang.IllegalArgumentException
- if portBase is not a valid port
number. If numComponents is neither 1 nor 2.java.io.IOException
- if an error occurs while the underlying resolver
is using sockets.java.net.BindException
- if we couldn't find a free port between within the
default number of retries.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.