|
Jitsi: the OpenSource Java VoIP and Instant Messaging client. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.java.sip.communicator.impl.netaddr.NetworkAddressManagerServiceImpl
public class NetworkAddressManagerServiceImpl
This implementation of the Network Address Manager allows you to intelligently retrieve the address of your localhost according to the destinations that you will be trying to reach. It also provides an interface to the ICE implementation in ice4j.
| Field Summary | |
|---|---|
static String |
BIND_RETRIES_PROPERTY_NAME
The name of the property containing the number of binds that we should should execute in case a port is already bound to (each retry would be on a new random port). |
static int |
DEFAULT_STUN_SERVER_PORT
Default STUN server port. |
(package private) DatagramSocket |
localHostFinderSocket
The socket that we use for dummy connections during selection of a local address that has to be used when communicating with a specific location. |
static String |
STUN_SRV_NAME
The service name to use when discovering STUN servers through DNS using SRV requests as per RFC 5389. |
static String |
TURN_SRV_NAME
The service name to use when discovering TURN servers through DNS using SRV requests as per RFC 5766. |
| Fields inherited from interface net.java.sip.communicator.service.netaddr.NetworkAddressManagerService |
|---|
BIND_RETRIES_DEFAULT_VALUE |
| Constructor Summary | |
|---|---|
NetworkAddressManagerServiceImpl()
|
|
| Method Summary | |
|---|---|
void |
addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
Adds new NetworkConfigurationChangeListener which will be informed for network configuration changes. |
DatagramSocket |
createDatagramSocket(InetAddress laddr,
int preferredPort,
int minPort,
int maxPort)
Creates a DatagramSocket and binds it to 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 rtpPort,
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(String domainName,
byte[] userName,
byte[] password)
Tries to discover a TURN or a STUN server for the specified domainName. |
byte[] |
getHardwareAddress(NetworkInterface iface)
Returns the hardware address (i.e. |
InetAddress |
getLocalHost(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. |
InetSocketAddress |
getPublicAddressFor(InetAddress dst,
int port)
Tries to obtain an for the specified port. |
void |
propertyChange(PropertyChangeEvent evt)
This method gets called when a bound property is changed. |
void |
removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
Remove NetworkConfigurationChangeListener. |
void |
start()
Initializes this network address manager service implementation. |
void |
stop()
Kills all threads/processes launched by this thread (if any) and prepares it for shutdown. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
DatagramSocket localHostFinderSocket
public static final String BIND_RETRIES_PROPERTY_NAME
public static final int DEFAULT_STUN_SERVER_PORT
public static final String TURN_SRV_NAME
public static final String STUN_SRV_NAME
| Constructor Detail |
|---|
public NetworkAddressManagerServiceImpl()
| Method Detail |
|---|
public void start()
public void stop()
public InetAddress getLocalHost(InetAddress intendedDestination)
getLocalHost in interface NetworkAddressManagerServiceintendedDestination - the destination that we'd like to use the
localhost address with.
public byte[] getHardwareAddress(NetworkInterface iface)
getHardwareAddress in interface NetworkAddressManagerServiceiface - the NetworkInterface
public InetSocketAddress getPublicAddressFor(InetAddress dst,
int port)
throws IOException,
BindException
getPublicAddressFor in interface NetworkAddressManagerServicedst - the destination that we'd like to use this address with.port - the port whose mapping we are interested in.
IOException - if an error occurs while creating the socket.
BindException - if the port is already in use.public void propertyChange(PropertyChangeEvent evt)
evt - A PropertyChangeEvent object describing the event source
and the property that has changed.
public DatagramSocket createDatagramSocket(InetAddress laddr,
int preferredPort,
int minPort,
int maxPort)
throws IllegalArgumentException,
IOException,
BindException
createDatagramSocket in interface NetworkAddressManagerServiceladdr - 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.
IllegalArgumentException - if either minPort or
maxPort is not a valid port number or if minPort >
maxPort.
IOException - if an error occurs while the underlying resolver lib
is using sockets.
BindException - if we couldn't find a free port between
minPort and maxPort before reaching the maximum allowed
number of retries.public void addNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
addNetworkConfigurationChangeListener in interface NetworkAddressManagerServicelistener - the listener.public void removeNetworkConfigurationChangeListener(NetworkConfigurationChangeListener listener)
removeNetworkConfigurationChangeListener in interface NetworkAddressManagerServicelistener - the listener.public org.ice4j.ice.Agent createIceAgent()
createIceAgent in interface NetworkAddressManagerService
public org.ice4j.ice.harvest.StunCandidateHarvester discoverStunServer(String domainName,
byte[] userName,
byte[] password)
discoverStunServer in interface NetworkAddressManagerServicedomainName - 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 domainName
public org.ice4j.ice.IceMediaStream createIceStream(int rtpPort,
String streamName,
org.ice4j.ice.Agent agent)
throws IllegalArgumentException,
IOException,
BindException
createIceStream in interface NetworkAddressManagerServicertpPort - 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.
IllegalArgumentException - if rtpPort is not a valid port
number.
IOException - if an error occurs while the underlying resolver
is using sockets.
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. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||