diff --git a/src/org/ice4j/NetAccessPointDescriptor.java b/src/org/ice4j/NetAccessPointDescriptor.java deleted file mode 100644 index 9d4366a..0000000 --- a/src/org/ice4j/NetAccessPointDescriptor.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - -package org.ice4j; - -/** - * The class is used to represent an [address]:[port] couple where the Stun4J - * stack is to listen for incoming messages. We need such a class so that we - * could identify and manage (add, remove, etc.) DatagramListeners. - * - * @author Emil Ivov - */ - -public class NetAccessPointDescriptor -{ - - /** - * The address string representing the host (interface) where the stack - * should bind. - */ - protected TransportAddress stunAddr = null; - - - /** - * Creates a net access point that will bind to the specified address. - * - * @param address a valid Stun Address. - */ - public NetAccessPointDescriptor(TransportAddress address) - { - stunAddr = address; - } - - /** - * Attempts to automatically detect the address of local host and binds - * on the specified port. - * - * @param port the port where to bind. - */ -/* public NetAccessPointDescriptor(int port) - { - stunAddr = new StunAddress(port); - } - */ - - /** - * Compares this object against the specified object. The result is true if - * and only if the argument is not null and it represents the same address - * as this object. - * - * Two instances of InetSocketAddress represent the same address if both the - * InetAddresses (or hostnames if it is unresolved) and port numbers are - * equal. If both addresses are unresolved, then the hostname & the port - * number are compared. - * - * @param obj the object to compare against. - * @return true if the objects are the same; false otherwise. - */ - public final boolean equals(Object obj) - { - if(obj == null - || !(obj instanceof NetAccessPointDescriptor)) - return false; - - if (obj == this) - return true; - - return stunAddr.equals( ((NetAccessPointDescriptor)obj).stunAddr ); - } - - /** - * Returns the socket address wrapped by this class. - * @return an InetSocketAddress instance. - */ - public TransportAddress getAddress() - { - return stunAddr; - } - - /** - * Clones the NetAccessPointDescriptor. - * - * @return a copy of this NetAccessPointDescriptor. - */ - public Object clone() - { - NetAccessPointDescriptor napd = new NetAccessPointDescriptor(stunAddr); - - return napd; - } - - - /** - * Returns the hashcode of this NetAccessPointDescriptor so that it could - * be used as a key in hashtables. - * - * @return the hashcode of this NetAccessPointDescriptor - */ - public int hashCode(){ - //we could actually simply return the hashcode of the socket address - //since it identifies us more or less uniquely - return stunAddr.getSocketAddress().hashCode(); - } - - /** - * Returns a string representation of this NetAccessPointDescriptor. - * - * @return a string representation of the object. - */ - public String toString() - { - - return "StunAddress=" + ( (stunAddr==null)? "null":stunAddr.toString()); - } -} diff --git a/src/org/ice4j/StunMessageEvent.java b/src/org/ice4j/StunMessageEvent.java index 49b782f..927645a 100644 --- a/src/org/ice4j/StunMessageEvent.java +++ b/src/org/ice4j/StunMessageEvent.java @@ -1,8 +1,8 @@ /* - * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * Maintained by the SIP Communicator community (http://sip-communicator.org). * - * Distributable under LGPL license. - * See terms of license at gnu.org. + * Distributable under LGPL license. See terms of license at gnu.org. */ package org.ice4j; @@ -40,27 +40,27 @@ public class StunMessageEvent /** * Constructs a StunMessageEvent according to the specified message. - * @param source the access point that received the message + * @param sourceAddress the access point that received the message * @param message the message itself * @param remoteAddress the address that sent the message */ - public StunMessageEvent(NetAccessPointDescriptor source, - Message message, - TransportAddress remoteAddress) + public StunMessageEvent(TransportAddress sourceAddress, + Message message, + TransportAddress remoteAddress) { - super(source); + super(sourceAddress); this.message = message; this.remoteAddress = remoteAddress; } /** - * Returns a NetAccessPointDescriptor referencing the access point where the - * message was received. + * Returns a TransportAddress referencing the access point where + * the message was received. * @return a descriptor of the access point where the message arrived. */ - public NetAccessPointDescriptor getSourceAccessPoint() + public TransportAddress getLocalAddress() { - return (NetAccessPointDescriptor)getSource(); + return (TransportAddress)getSource(); } /** diff --git a/src/org/ice4j/TransportAddress.java b/src/org/ice4j/TransportAddress.java index f1f6997..34300ad 100644 --- a/src/org/ice4j/TransportAddress.java +++ b/src/org/ice4j/TransportAddress.java @@ -1,8 +1,8 @@ /* - * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * Maintained by the SIP Communicator community (http://sip-communicator.org). * - * Distributable under LGPL license. - * See terms of license at gnu.org. + * Distributable under LGPL license. See terms of license at gnu.org. */ package org.ice4j; @@ -29,34 +29,14 @@ public class TransportAddress */ private final Transport transport; - /** - * Creates an address instance address from an IP address and a port number - * and UDP transport. - *
- * A valid port value is between 0 and 65535.
- * A port number of zero will let the system pick up an
- * ephemeral port in a bind operation.
- *
- * A null address will assign the wildcard address.
- *
- * @param hostname The IP address - * @param port The port number - * @throws IllegalArgumentException if the port parameter is outside the - * specified range of valid port values. - */ - public TransportAddress(String hostname, int port) - { - this(hostname, port, Transport.UDP); - } - /** * Creates an address instance address from an IP address and a port number. *
* A valid port value is between 0 and 65535.
- * A port number of zero will let the system pick up an
- * ephemeral port in a bind operation.
+ * A port number of zero will let the system pick up an
+ * ephemeral port in a bind operation.
*
- * A null address will assign the wildcard address.
+ * A null address will assign the wildcard address.
*
* @param hostname The IP address * @param port The port number @@ -67,7 +47,7 @@ public class TransportAddress public TransportAddress(String hostname, int port, Transport transport) { socketAddress = new InetSocketAddress(hostname, port); - this.transport = Transport.UDP; + this.transport = transport; } /** @@ -75,18 +55,20 @@ public class TransportAddress * address and a port number. *
* A valid port value is between 0 and 65535.
- * A port number of zero will let the system pick up an
- * ephemeral port in a bind operation.
+ * A port number of zero will let the system pick up an
+ * ephemeral port in a bind operation.
*
- * A null address will assign the wildcard address.
+ * A null address will assign the wildcard address.
*
* @param ipAddress The IP address * @param port The port number + * @param transport The Transport to use with this address. + * * @throws IllegalArgumentException if the port parameter is outside the - * specified range of valid port values or if ipAddress is not a valid ip + * specified range of valid port values or if ipAddress is not a valid IP * address. */ - public TransportAddress(byte[] ipAddress, int port) + public TransportAddress(byte[] ipAddress, int port, Transport transport) { try @@ -104,7 +86,7 @@ public class TransportAddress port); } - transport = Transport.UDP; + this.transport = transport; } @@ -114,41 +96,22 @@ public class TransportAddress * An attempt will be made to resolve the hostname into an InetAddress. * If that attempt fails, the address will be flagged as unresolved. *
- * A valid port value is between 0 and 65535.
- * A port number of zero will let the system pick up an
- * ephemeral port in a bind operation.
- *
- * @param address the address itself - * @param port the port number + * A valid port value is between 0 and 65535. A port number of zero will + * let the system pick up an ephemeral port in a bind operation. + *
+ * @param address the address itself + * @param port the port number + * @param transport the transport to use with this address. + * * @throws IllegalArgumentException if the port parameter is outside the * range of valid port values, or if the hostname parmeter is null. */ - public TransportAddress(InetAddress address, int port) + public TransportAddress(InetAddress address, int port, Transport transport) { socketAddress = new InetSocketAddress(address, port); - transport = Transport.UDP; + this.transport = transport; } - /** - * Creates an address instance from the localhost amd a port number. - *
- * Addresses created with this constructor should be used cautiously as
- * they won't be trated as equal to address created from the localhost
- * address even though the represent the same thing. In other words - use
- * this constructor only if you're not going to compare the resulting
- * instance with other addresses.
- *
- * @param port the port number
- * @throws IllegalArgumentException if the port parameter is outside the
- * range of valid port values, or if the hostname parmeter is null.
- */
- public TransportAddress(int port)
- {
- socketAddress = new InetSocketAddress(port);
- transport = Transport.UDP;
- }
-
-
/**
* Returns the raw IP address of this Address object. The result is in
* network byte order: the highest order byte of the address is in
@@ -163,7 +126,7 @@ public class TransportAddress
}
/**
- * Returns the port number or 0 if the addres has not been initialized.
+ * Returns the port number or 0 if the address has not been initialized.
* @return the port number.
*/
public int getPort()
diff --git a/src/org/ice4j/stack/EventDispatcher.java b/src/org/ice4j/stack/EventDispatcher.java
index 1451442..979f366 100644
--- a/src/org/ice4j/stack/EventDispatcher.java
+++ b/src/org/ice4j/stack/EventDispatcher.java
@@ -1,9 +1,8 @@
-
/*
- * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal.
+ * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
+ * Maintained by the SIP Communicator community (http://sip-communicator.org).
*
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ * Distributable under LGPL license. See terms of license at gnu.org.
*/
package org.ice4j.stack;
@@ -15,7 +14,7 @@ import org.ice4j.*;
/**
* This is a utility class used for dispatching incoming request events. We use
* this class mainly (and probably solely) for its ability to handle listener
- * proxies (i.e. listeners interested in requests recevied on a particular
+ * proxies (i.e. listeners interested in requests received on a particular
* NetAccessPoint only).
*
* @author Emil Ivov
@@ -32,10 +31,11 @@ public class EventDispatcher
* Hashtable for managing property change listeners registered for specific
* properties. Maps property names to PropertyChangeSupport objects.
*/
- private Hashtable Organisation: Louis Pasteur University, Strasbourg, France Network Research Team (http://www-r2.u-strasbg.fr)EventDispatcher object.
+ * Constructs an EventDispatcher object.
*/
public EventDispatcher()
{
@@ -63,23 +63,23 @@ public class EventDispatcher
* will be invoked only when a call on fireRequestReceived is issued for
* that specific NetAccessPoint.
*
- * @param descriptor The NETAP descriptor that we're interested in.
+ * @param localAddr The NETAP descriptor that we're interested in.
* @param listener The ConfigurationChangeListener to be added
*/
- public synchronized void addRequestListener(
- NetAccessPointDescriptor descriptor,
- RequestListener listener)
+ public synchronized void addRequestListener( TransportAddress localAddr,
+ RequestListener listener)
{
if (requestListenersChildren == null)
{
- requestListenersChildren = new Hashtable
Organisation:
Louis Pasteur University, Strasbourg, France
- *Network Research Team (http://www-r2.u-strasbg.fr)
* @author Emil Ivov - * @version 0.1 */ class StunServerTransaction @@ -48,7 +44,7 @@ class StunServerTransaction /** * The StunProvider that created us. */ - private StunProvider providerCallback = null; + private StunProvider providerCallback = null; /** * The source of the transaction request. @@ -61,17 +57,17 @@ class StunServerTransaction private Response response = null; /** - * The ap descriptor used when sending the response + * The TransportAddress we use when sending responses */ - private NetAccessPointDescriptor apDescriptor = null; + private TransportAddress localAddress = null; /** * The id of the transaction. */ - private TransactionID transactionID = null; + private TransactionID transactionID = null; /** - * The date (in millis) when the next retransmission should follow. + * The date (in milliseconds) when the next retransmission should follow. */ private long expirationDate = -1; @@ -140,7 +136,7 @@ class StunServerTransaction * the transaction's state to retransmitting. * * @param response the response to send the transaction to. - * @param sendThrough the NetAccessPoint through which the response is to + * @param sendThrough the local address through which the response is to * be sent * @param sendTo the destination of the response. * @@ -150,9 +146,9 @@ class StunServerTransaction * access point that had not been installed, * @throws StunException if message encoding fails, */ - void sendResponse(Response response, - NetAccessPointDescriptor sendThrough, - TransportAddress sendTo) + public void sendResponse(Response response, + TransportAddress sendThrough, + TransportAddress sendTo) throws StunException, IOException, IllegalArgumentException @@ -162,7 +158,7 @@ class StunServerTransaction //the transaction id might already have been set, but its our job //to make sure of that response.setTransactionID(this.transactionID.getTransactionID()); - this.apDescriptor = sendThrough; + this.localAddress = sendThrough; this.responseDestination = sendTo; } @@ -180,7 +176,7 @@ class StunServerTransaction * access point that had not been installed, * @throws StunException if message encoding fails, */ - void retransmitResponse() + private void retransmitResponse() throws StunException, IOException, IllegalArgumentException @@ -191,15 +187,15 @@ class StunServerTransaction return; providerCallback.getNetAccessManager().sendMessage(response, - apDescriptor, + localAddress, responseDestination); } /** * Waits until next retransmission is due or until the transaction is - * cancelled (whichever comes first). + * canceled (whichever comes first). */ - synchronized void waitNextScheduledDate() + private synchronized void waitNextScheduledDate() { long current = System.currentTimeMillis(); while(expirationDate - current > 0) @@ -221,9 +217,10 @@ class StunServerTransaction /** * Sets the expiration date for this server transaction. - * @param timeout the number of millis to wait before expiration. + * + * @param timeout the number of milliseconds to wait before expiration. */ - void schedule(long timeout) + private void schedule(long timeout) { this.expirationDate = System.currentTimeMillis() + timeout; } @@ -232,7 +229,7 @@ class StunServerTransaction * Cancels the transaction. Once this method is called the transaction is * considered terminated and will stop retransmissions. */ - synchronized void expire() + public synchronized void expire() { this.expired = true; notifyAll(); @@ -244,7 +241,7 @@ class StunServerTransaction * * @return the ID of the transaction. */ - TransactionID getTransactionID() + public TransactionID getTransactionID() { return this.transactionID; } @@ -252,9 +249,11 @@ class StunServerTransaction /** * Specifies whether this server transaction is in the retransmitting state. * Or in other words - has it already sent a first response or not? - * @return boolean + * + * @return true if this transaction is still retransmitting and + * false otherwise */ - boolean isReransmitting() + public boolean isReransmitting() { return isRetransmitting; } diff --git a/src/org/ice4j/stack/StunStack.java b/src/org/ice4j/stack/StunStack.java index 6e50c3f..a5beed1 100644 --- a/src/org/ice4j/stack/StunStack.java +++ b/src/org/ice4j/stack/StunStack.java @@ -1,25 +1,21 @@ /* - * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * Maintained by the SIP Communicator community (http://sip-communicator.org). * - * Distributable under LGPL license. - * See terms of license at gnu.org. + * Distributable under LGPL license. See terms of license at gnu.org. */ package org.ice4j.stack; -import java.net.DatagramSocket; import java.io.*; +import java.net.*; import org.ice4j.*; -import org.ice4j.message.*; /** * The entry point to the Stun4J stack. The class is used to start, stop and * configure the stack. * - *Organisation: Louis Pasteur University, Strasbourg, France
- *Network Research Team (http://www-r2.u-strasbg.fr)
* @author Emil Ivov - * @version 0.1 */ public class StunStack { @@ -69,49 +65,35 @@ public class StunStack netAccessManager.setThreadPoolSize(threadPoolSize); } - /** - * Creates and starts the specified Network Access Point. - * - * @param apDescriptor A descriptor containing the address and port of the - * STUN server that the newly created access point will communicate with. - * @throws IOException if we fail to bind a datagram socket on the specified - * address and port (NetAccessPointDescriptor) - */ - public void installNetAccessPoint(NetAccessPointDescriptor apDescriptor) - throws IOException - { - netAccessManager.installNetAccessPoint(apDescriptor); - } - /** * Creates and starts the specified Network Access Point based on the * specified socket and returns a relevant descriptor. * * @param sock The socket that the new access point should represent. * @throws IOException if we fail to setup the socket. - * @return a descriptor of the newly created access point. */ - public NetAccessPointDescriptor installNetAccessPoint(DatagramSocket sock) + public void installNetAccessPoint(DatagramSocket sock) throws IOException { - return netAccessManager.installNetAccessPoint(sock); + netAccessManager.installUdpConnector(sock); } /** - * Stops and deletes the specified access point. - * @param apDescriptor the access point to remove + * Stops and deletes the connector listening on the specified local address. + * + * @param localAddr the access point to remove */ - public void removeNetAccessPoint(NetAccessPointDescriptor apDescriptor) + public void removeNetAccessPoint(TransportAddress localAddr) { - netAccessManager.removeNetAccessPoint(apDescriptor); + netAccessManager.removeNetAccessPoint(localAddr); } /** * Returns a StunProvider instance to be used for sending and receiving - * mesages. + * messages. * * @return an instance of StunProvider */ diff --git a/src/org/ice4j/stunclient/BlockingRequestSender.java b/src/org/ice4j/stunclient/BlockingRequestSender.java index f73fc97..c711a24 100644 --- a/src/org/ice4j/stunclient/BlockingRequestSender.java +++ b/src/org/ice4j/stunclient/BlockingRequestSender.java @@ -1,26 +1,26 @@ /* - * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * Maintained by the SIP Communicator community (http://sip-communicator.org). * - * Distributable under LGPL license. - * See terms of license at gnu.org. + * Distributable under LGPL license. See terms of license at gnu.org. */ package org.ice4j.stunclient; -import java.util.logging.*; import java.io.*; +import java.util.logging.*; import org.ice4j.*; import org.ice4j.message.*; import org.ice4j.stack.*; /** - * A utility used to flatten the multithreaded architecture of the Stack + * A utility used to flatten the multi-thread architecture of the Stack * and execute the discovery process in a synchronized manner. Roughly what * happens here is: - * + *
* ApplicationThread:
* sendMessage()
- * wait();
+ * wait();
*
* StackThread:
* processMessage/Timeout()
@@ -28,32 +28,57 @@ import org.ice4j.stack.*;
* saveMessage();
* notify();
* }
+ *
*
- *
- * Organisation:
Louis Pasteur University, Strasbourg, France
- *Network Research Team (http://www-r2.u-strasbg.fr)
* @author Emil Ivov - * @version 0.1 */ class BlockingRequestSender implements ResponseCollector { - private static final Logger logger = - Logger.getLogger(BlockingRequestSender.class.getName()); + /** + * Our class logger + */ + private static final Logger logger + = Logger.getLogger(BlockingRequestSender.class.getName()); - private StunProvider stunProvider = null; - private NetAccessPointDescriptor apDescriptor = null; + /** + * The provider that we are using to send requests through. + */ + private StunProvider stunProvider = null; - StunMessageEvent responseEvent = null; + /** + * The transport address that we are bound on. + */ + private TransportAddress localAddress = null; + /** + * The StunMessageEvent that contains the response matching our + * request. + */ + private StunMessageEvent responseEvent = null; + + /** + * Determines whether this request sender has comleted its coarse. + */ private boolean ended = false; - private Object sendLock = new Object(); - BlockingRequestSender(StunProvider stunProvider, - NetAccessPointDescriptor apDescriptor) + /** + * A lock object that we are using to synchronize sending. + */ + private Object sendLock = new Object(); + + /** + * Creates a new request sender. + * @param stunProvider the provider that the sender should send requests + * through. + * @param localAddress the TransportAddress that requests should be + * leaving from. + */ + BlockingRequestSender(StunProvider stunProvider, + TransportAddress localAddress) { this.stunProvider = stunProvider; - this.apDescriptor = apDescriptor; + this.localAddress = localAddress; } /** @@ -71,7 +96,7 @@ class BlockingRequestSender } /** - * Notifies the discoverer thread when a message has timeouted so that + * Notifies the discoverer thread when a message has timeout-ed so that * it may resume and consider it as unanswered. */ public synchronized void processTimeout() @@ -85,7 +110,7 @@ class BlockingRequestSender /** * Sends the specified request and blocks until a response has been * received or the request transaction has timed out. - * @param request the reuqest to send + * @param request the request to send * @param serverAddress the request destination address * @return the event encapsulating the response or null if no response * has been received. @@ -97,13 +122,13 @@ class BlockingRequestSender * @throws StunException if message encoding fails, */ public synchronized StunMessageEvent sendRequestAndWaitForResponse( - Request request, - TransportAddress serverAddress) + Request request, + TransportAddress serverAddress) throws StunException, IOException { synchronized(sendLock){ - stunProvider.sendRequest(request, serverAddress, apDescriptor, + stunProvider.sendRequest(request, serverAddress, localAddress, BlockingRequestSender.this); } diff --git a/src/org/ice4j/stunclient/NetworkConfigurationDiscoveryProcess.java b/src/org/ice4j/stunclient/NetworkConfigurationDiscoveryProcess.java index 10c3591..afce620 100644 --- a/src/org/ice4j/stunclient/NetworkConfigurationDiscoveryProcess.java +++ b/src/org/ice4j/stunclient/NetworkConfigurationDiscoveryProcess.java @@ -1,15 +1,14 @@ /* - * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * Maintained by the SIP Communicator community (http://sip-communicator.org). * - * Distributable under LGPL license. - * See terms of license at gnu.org. + * Distributable under LGPL license. See terms of license at gnu.org. */ package org.ice4j.stunclient; -import java.net.*; - -import java.util.logging.*; import java.io.*; +import java.net.*; +import java.util.logging.*; import org.ice4j.*; import org.ice4j.attribute.*; @@ -85,6 +84,9 @@ import org.ice4j.stack.*; public class NetworkConfigurationDiscoveryProcess { + /** + * Our class logger. + */ private static final Logger logger = Logger.getLogger(NetworkConfigurationDiscoveryProcess.class.getName()); /** @@ -96,52 +98,46 @@ public class NetworkConfigurationDiscoveryProcess /** * The stack to use for STUN communication. */ - private StunStack stunStack = null; + private StunStack stunStack = null; /** * The provider to send our messages through */ - private StunProvider stunProvider = null; + private StunProvider stunProvider = null; /** * The point where we'll be listening. */ - private NetAccessPointDescriptor apDescriptor = null; + private TransportAddress localAddress = null; /** * The address of the stun server */ - private TransportAddress serverAddress = null; + private TransportAddress serverAddress = null; /** - * A utility used to flatten the multithreaded architecture of the Stack + * A utility used to flatten the multi thread architecture of the Stack * and execute the discovery process in a synchronized manner */ - private BlockingRequestSender requestSender = null; + private BlockingRequestSender requestSender = null; + + /** + * The DatagramSocket that we are going to be running the + * discovery process through. + */ + private DatagramSocket sock = null; /** * Creates a StunAddressDiscoverer. In order to use it one must start the * discoverer. - * @param localAddress the address where the stach should bind. + * + * @param localAddress the address where the stack should bind. * @param serverAddress the address of the server to interrogate. */ public NetworkConfigurationDiscoveryProcess(TransportAddress localAddress, - TransportAddress serverAddress) + TransportAddress serverAddress) { - apDescriptor = new NetAccessPointDescriptor(localAddress); - this.serverAddress = serverAddress; - } - - /** - * Creates a StunAddressDiscoverer. In order to use it one must start the - * discoverer. - * @param apDescriptor the address where the stach should bind. - * @param serverAddress the address of the server to interrogate. - */ - public NetworkConfigurationDiscoveryProcess(NetAccessPointDescriptor apDescriptor, - TransportAddress serverAddress) - { - this.apDescriptor = apDescriptor; + this.localAddress = localAddress; this.serverAddress = serverAddress; } @@ -154,7 +150,7 @@ public class NetworkConfigurationDiscoveryProcess { stunStack = null; stunProvider = null; - apDescriptor = null; + localAddress = null; requestSender = null; this.started = false; @@ -171,11 +167,13 @@ public class NetworkConfigurationDiscoveryProcess { stunStack = StunStack.getInstance(); - stunStack.installNetAccessPoint(apDescriptor); + DatagramSocket sock + = new DatagramSocket(localAddress.getSocketAddress()); + + stunStack.installNetAccessPoint(sock); stunProvider = stunStack.getProvider(); - - requestSender = new BlockingRequestSender(stunProvider, apDescriptor); + requestSender = new BlockingRequestSender(stunProvider, localAddress); started = true; } @@ -228,7 +226,7 @@ public class NetworkConfigurationDiscoveryProcess + ", name=" + backupServerAddress.getHostAddress()); report.setPublicAddress(mappedAddress); - if (mappedAddress.equals(apDescriptor.getAddress())) + if (mappedAddress.equals(localAddress)) { evt = doTestII(serverAddress); if (evt == null) @@ -260,7 +258,8 @@ public class NetworkConfigurationDiscoveryProcess } TransportAddress mappedAddress2 = ((MappedAddressAttribute)evt.getMessage(). - getAttribute(Attribute.MAPPED_ADDRESS)).getAddress(); + getAttribute(Attribute.MAPPED_ADDRESS)) + .getAddress(); if(mappedAddress.equals(mappedAddress2)) { evt = doTestIII(serverAddress); @@ -322,7 +321,8 @@ public class NetworkConfigurationDiscoveryProcess changeRequest.setChangePortFlag(false); */ /* add a change request attribute */ - ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute(); + ChangeRequestAttribute changeRequest + = AttributeFactory.createChangeRequestAttribute(); changeRequest.setChangeIpFlag(false); changeRequest.setChangePortFlag(false); request.addAttribute(changeRequest); @@ -367,7 +367,9 @@ public class NetworkConfigurationDiscoveryProcess { Request request = MessageFactory.createBindingRequest(); - /* ChangeRequestAttribute changeRequest = (ChangeRequestAttribute)request.getAttribute(Attribute.CHANGE_REQUEST); */ + /* ChangeRequestAttribute changeRequest + * = (ChangeRequestAttribute)request + * .getAttribute(Attribute.CHANGE_REQUEST); */ /* add a change request attribute */ ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute(); changeRequest.setChangeIpFlag(true); diff --git a/src/org/ice4j/stunclient/SimpleAddressDetector.java b/src/org/ice4j/stunclient/SimpleAddressDetector.java index 8e83c62..0b3cc83 100644 --- a/src/org/ice4j/stunclient/SimpleAddressDetector.java +++ b/src/org/ice4j/stunclient/SimpleAddressDetector.java @@ -1,8 +1,8 @@ /* - * Stun4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * Maintained by the SIP Communicator community (http://sip-communicator.org). * - * Distributable under LGPL license. - * See terms of license at gnu.org. + * Distributable under LGPL license. See terms of license at gnu.org. */ package org.ice4j.stunclient; diff --git a/src/org/ice4j/stunclient/StunClient.java b/src/org/ice4j/stunclient/StunClient.java deleted file mode 100755 index 6af6ff7..0000000 --- a/src/org/ice4j/stunclient/StunClient.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.ice4j.stunclient; - -import java.io.IOException; -import java.util.HashMap; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.ice4j.*; -import org.ice4j.attribute.*; -import org.ice4j.message.*; -import org.ice4j.stack.*; -import org.ice4j.stunclient.*; - - -/** - * The interface given to the ICE agent to send STUN requests - * and receive responses - * - * @author Namal Senarathne - */ -public class StunClient - implements ResponseCollector -{ - - private final Logger logger = - Logger.getLogger(StunClient.class.getName()); - - /** - * The STUN stack - */ - private StunStack stunStack = null; - - /** - * The Stun Provider from the stack - */ - private StunProvider stunProvider = null; - - /** - * The HashMap used to store the sent requests and correlate between - * the responses and the requests. - * This data structure is used only when sendStunRequest message is invoked - */ - private HashMap