diff --git a/src/org/ice4j/attribute/UsernameAttribute.java b/src/org/ice4j/attribute/UsernameAttribute.java
index d763f9b..1e5e745 100644
--- a/src/org/ice4j/attribute/UsernameAttribute.java
+++ b/src/org/ice4j/attribute/UsernameAttribute.java
@@ -8,8 +8,6 @@ package org.ice4j.attribute;
import java.util.*;
-import org.ice4j.*;
-
/**
* The USERNAME attribute is used for message integrity.
* The value of USERNAME is a variable length value.
@@ -91,6 +89,7 @@ public class UsernameAttribute extends Attribute
/**
* Returns the human readable name of this attribute.
+ *
* @return this attribute's name.
*/
public String getName()
@@ -101,6 +100,7 @@ public class UsernameAttribute extends Attribute
/**
* Returns a (cloned) byte array containing the data value of the username
* attribute.
+ *
* @return the binary array containing the username.
*/
public byte[] getUsername()
@@ -136,6 +136,7 @@ public class UsernameAttribute extends Attribute
* they have the same type length and value.
*
* @param obj the object to compare this attribute with.
+ *
* @return true if the attributes are equal and false otherwise.
*/
public boolean equals(Object obj)
diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java
index 391e9e2..3457c7b 100644
--- a/src/org/ice4j/ice/Agent.java
+++ b/src/org/ice4j/ice/Agent.java
@@ -102,6 +102,13 @@ public class Agent
*/
private boolean isControlling = true;
+ /**
+ * The entity that will be taking care of all incoming and outgoing
+ * connectivity checks.
+ */
+ private final ConnectivityCheckHandler connCheckHandler
+ = new ConnectivityCheckHandler(this);
+
/**
* Creates an empty Agent with no streams, and no address
*/
@@ -114,7 +121,12 @@ public class Agent
tieBreaker = Math.abs(random.nextLong());
- System.setProperty(StackProperties.SOFTWARE, "ice4j.org");
+ //add the software attribute to all messages
+ String sware = StackProperties.getString(StackProperties.SOFTWARE);
+ if( sware == null)
+ System.setProperty(StackProperties.SOFTWARE, "ice4j.org");
+
+ //add the FINGERPRINT attribute to all messages.
System.setProperty(StackProperties.ALWAYS_SIGN, "true");
}
@@ -242,13 +254,11 @@ public class Agent
List streams = getStreams();
- ConnectivityCheckDispatcher client
- = new ConnectivityCheckDispatcher(this);
for(IceMediaStream stream : streams)
{
CheckList list = stream.getCheckList();
- client.startChecks(list);
+ connCheckHandler.startChecks(list);
}
}
diff --git a/src/org/ice4j/ice/ConnectivityCheckDispatcher.java b/src/org/ice4j/ice/ConnectivityCheckDispatcher.java
deleted file mode 100644
index 7552bf1..0000000
--- a/src/org/ice4j/ice/ConnectivityCheckDispatcher.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 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.
- */
-package org.ice4j.ice;
-
-import java.net.*;
-import java.util.logging.*;
-
-import org.ice4j.*;
-import org.ice4j.attribute.*;
-import org.ice4j.message.*;
-import org.ice4j.socket.*;
-import org.ice4j.stack.*;
-
-/**
- * @author Emil Ivov
- */
-public class ConnectivityCheckDispatcher
- implements ResponseCollector, RequestListener
-{
- /**
- * The Logger used by the ConnectivityCheckClient
- * class and its instances for logging output.
- */
- private static final Logger logger = Logger
- .getLogger(ConnectivityCheckDispatcher.class.getName());
-
- private final Agent parentAgent;
-
- /**
- * The stun stack that we will use for connectivity checks.
- */
- StunStack stunStack = StunStack.getInstance();
-
- /**
- * The DatagramPacketFilter that only accepts STUN messages.
- */
- private DatagramPacketFilter stunDatagramPacketFilter;
-
- public ConnectivityCheckDispatcher(Agent parentAgent)
- {
- stunStack.addRequestListener(this);
- this.parentAgent = parentAgent;
- }
-
- public void startChecks(CheckList checkList)
- {
- for(CandidatePair pair : checkList)
- {
- startCheckForPair(pair);
- }
- }
-
-
- private void startCheckForPair(CandidatePair pair)
- {
- //we don't need to do a canReach() verification here as it has been
- //already verified during the gathering process.
- DatagramSocket stunSocket = ((HostCandidate)pair.getLocalCandidate())
- .getStunSocket(null);
-
- Request request = MessageFactory.createBindingRequest();
-
- //priority
- PriorityAttribute priority = AttributeFactory.createPriorityAttribute(
- pair.getLocalCandidate().computePriorityForType(
- CandidateType.PEER_REFLEXIVE_CANDIDATE));
-
- request.addAttribute(priority);
-
- //controlling controlled
- if (parentAgent.isControlling())
- {
- request.addAttribute(AttributeFactory
- .createIceControllingAttribute(parentAgent
- .getTieBreaker()));
- }
- else
- {
- request.addAttribute(AttributeFactory
- .createIceControlledAttribute(parentAgent
- .getTieBreaker()));
- }
-
- //credentials
- UsernameAttribute unameAttr = AttributeFactory.createUsernameAttribute(
- parentAgent.generateLocalUserName());
-
- request.addAttribute(unameAttr);
-
- //todo: do this in the stun stack so that we could do the
- //calculation once the request is ready (we'd need the transaction id
- //for example.
- //todo: also implement SASL prepare
- MessageIntegrityAttribute msgIntegrity
- = AttributeFactory.createMessageIntegrityAttribute(
- parentAgent.getPassword().getBytes());
-
-
- request.addAttribute(msgIntegrity);
-
- TransactionID tran;
-
- try
- {
-
-
- tran = stunStack.sendRequest(request,
- pair.getRemoteCandidate().getTransportAddress(), stunSocket,
- this);
-
-System.out.println("checking pair " + pair + " with tran=" + tran.toString());
- }
- catch (Exception exception)
- {
- logger.log(
- Level.INFO,
- "Failed to send " + request + " through "
- + stunSocket.getLocalSocketAddress(),
- exception);
- return;
- }
- }
-
- public void processResponse(StunMessageEvent response)
- {
- }
-
- public void processTimeout(StunTimeoutEvent event)
- {
- System.out.println("timeout event=" + event);
- }
-
- public void processUnreachable(StunFailureEvent event)
- {
- System.out.println("failure event=" + event);
- }
-
- int i;
- public void requestReceived(StunMessageEvent evt)
- {
- Response response = MessageFactory.createBindingResponse(
- (Request)evt.getMessage(), evt.getRemoteAddress());
-
- try
- {
- stunStack.sendResponse(evt.getTransactionID().getTransactionID(),
- response, evt.getLocalAddress(), evt.getRemoteAddress());
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}