parent
adca67b17f
commit
9dc08bd299
40
checkstyle.xml
Normal file
40
checkstyle.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||||
|
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
|
||||||
|
<module name="SuppressWithPlainTextCommentFilter"/>
|
||||||
|
|
||||||
|
<module name="LineLength">
|
||||||
|
<property name="fileExtensions" value="java"/>
|
||||||
|
<property name="max" value="120"/>
|
||||||
|
<property name="ignorePattern" value="http://|https://"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<module name="LeftCurly">
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
<property name="tokens" value="LITERAL_CATCH"/>
|
||||||
|
<property name="tokens" value="LITERAL_ELSE"/>
|
||||||
|
<property name="tokens" value="LITERAL_FINALLY"/>
|
||||||
|
<property name="tokens" value="LITERAL_IF"/>
|
||||||
|
<property name="tokens" value="LITERAL_TRY"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Skips empty blocks {}, to not skip them: value="alone" -->
|
||||||
|
<module name="RightCurly">
|
||||||
|
<property name="option" value="alone_or_singleline"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="WhitespaceAfter">
|
||||||
|
<!-- Drops TYPECAST from default tokens -->
|
||||||
|
<property name="tokens" value="COMMA , SEMI , LITERAL_IF , LITERAL_ELSE , LITERAL_WHILE , LITERAL_DO , LITERAL_FOR , DO_WHILE"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="FileTabCharacter">
|
||||||
|
<property name="eachLine" value="true"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
||||||
15
pom.xml
15
pom.xml
@ -191,6 +191,21 @@
|
|||||||
</compilerArgs>
|
</compilerArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.github.gantsign.maven</groupId>
|
<groupId>com.github.gantsign.maven</groupId>
|
||||||
<artifactId>ktlint-maven-plugin</artifactId>
|
<artifactId>ktlint-maven-plugin</artifactId>
|
||||||
|
|||||||
@ -99,22 +99,22 @@ public enum Transport
|
|||||||
public static Transport parse(String transportName)
|
public static Transport parse(String transportName)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(UDP.toString().equals(transportName))
|
if (UDP.toString().equals(transportName))
|
||||||
return UDP;
|
return UDP;
|
||||||
|
|
||||||
if(TCP.toString().equals(transportName))
|
if (TCP.toString().equals(transportName))
|
||||||
return TCP;
|
return TCP;
|
||||||
|
|
||||||
if(TLS.toString().equals(transportName))
|
if (TLS.toString().equals(transportName))
|
||||||
return TLS;
|
return TLS;
|
||||||
|
|
||||||
if(SCTP.toString().equals(transportName))
|
if (SCTP.toString().equals(transportName))
|
||||||
return SCTP;
|
return SCTP;
|
||||||
|
|
||||||
if(DTLS.toString().equals(transportName))
|
if (DTLS.toString().equals(transportName))
|
||||||
return DTLS;
|
return DTLS;
|
||||||
|
|
||||||
if(SSLTCP.toString().equals(transportName))
|
if (SSLTCP.toString().equals(transportName))
|
||||||
return SSLTCP;
|
return SSLTCP;
|
||||||
|
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|||||||
@ -148,14 +148,14 @@ public class TransportAddress
|
|||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
String hostAddress = getHostAddress();
|
String hostAddress = getHostAddress();
|
||||||
if(hostAddress == null)
|
if (hostAddress == null)
|
||||||
{
|
{
|
||||||
hostAddress = getHostName();
|
hostAddress = getHostName();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder bldr = new StringBuilder(hostAddress);
|
StringBuilder bldr = new StringBuilder(hostAddress);
|
||||||
|
|
||||||
if(isIPv6())
|
if (isIPv6())
|
||||||
bldr.insert(0, "[").append("]");
|
bldr.insert(0, "[").append("]");
|
||||||
|
|
||||||
bldr.append(":").append(getPort());
|
bldr.append(":").append(getPort());
|
||||||
@ -175,7 +175,7 @@ public class TransportAddress
|
|||||||
String addressStr
|
String addressStr
|
||||||
= addr != null ? addr.getHostAddress() : null;
|
= addr != null ? addr.getHostAddress() : null;
|
||||||
|
|
||||||
if(addr instanceof Inet6Address)
|
if (addr instanceof Inet6Address)
|
||||||
addressStr = NetworkUtils.stripScopeID(addressStr);
|
addressStr = NetworkUtils.stripScopeID(addressStr);
|
||||||
|
|
||||||
return addressStr;
|
return addressStr;
|
||||||
@ -258,7 +258,7 @@ public class TransportAddress
|
|||||||
*/
|
*/
|
||||||
public boolean canReach(TransportAddress dst)
|
public boolean canReach(TransportAddress dst)
|
||||||
{
|
{
|
||||||
if( getTransport() != dst.getTransport() )
|
if ( getTransport() != dst.getTransport() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (isIPv6() != dst.isIPv6())
|
if (isIPv6() != dst.isIPv6())
|
||||||
@ -269,7 +269,7 @@ public class TransportAddress
|
|||||||
Inet6Address srcAddr = (Inet6Address)getAddress();
|
Inet6Address srcAddr = (Inet6Address)getAddress();
|
||||||
Inet6Address dstAddr = (Inet6Address)dst.getAddress();
|
Inet6Address dstAddr = (Inet6Address)dst.getAddress();
|
||||||
|
|
||||||
if(srcAddr.isLinkLocalAddress() != dstAddr.isLinkLocalAddress())
|
if (srcAddr.isLinkLocalAddress() != dstAddr.isLinkLocalAddress())
|
||||||
{
|
{
|
||||||
//this one may actually work if for example we are contacting
|
//this one may actually work if for example we are contacting
|
||||||
//the public address of someone in our local network. however
|
//the public address of someone in our local network. however
|
||||||
|
|||||||
@ -176,7 +176,7 @@ abstract class AddressAttribute extends Attribute
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
//addresses
|
//addresses
|
||||||
if( att.getAddress() == null && getAddress() == null)
|
if ( att.getAddress() == null && getAddress() == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -221,10 +221,12 @@ abstract class AddressAttribute extends Attribute
|
|||||||
binValue[7] = (byte)(getPort() & 0x00FF);
|
binValue[7] = (byte)(getPort() & 0x00FF);
|
||||||
|
|
||||||
//address
|
//address
|
||||||
if(getFamily() == ADDRESS_FAMILY_IPV6){
|
if (getFamily() == ADDRESS_FAMILY_IPV6)
|
||||||
|
{
|
||||||
System.arraycopy(getAddressBytes(), 0, binValue, 8, 16);
|
System.arraycopy(getAddressBytes(), 0, binValue, 8, 16);
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
System.arraycopy(getAddressBytes(), 0, binValue, 8, 4);
|
System.arraycopy(getAddressBytes(), 0, binValue, 8, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +309,7 @@ abstract class AddressAttribute extends Attribute
|
|||||||
|
|
||||||
//address
|
//address
|
||||||
byte address[] = null;
|
byte address[] = null;
|
||||||
if(family == ADDRESS_FAMILY_IPV6)
|
if (family == ADDRESS_FAMILY_IPV6)
|
||||||
{
|
{
|
||||||
address = new byte[16];
|
address = new byte[16];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class AttributeDecoder
|
|||||||
int length)
|
int length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(bytes == null || bytes.length < Attribute.HEADER_LENGTH)
|
if (bytes == null || bytes.length < Attribute.HEADER_LENGTH)
|
||||||
{
|
{
|
||||||
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
||||||
"Could not decode the specified binary array.");
|
"Could not decode the specified binary array.");
|
||||||
@ -59,7 +59,7 @@ public class AttributeDecoder
|
|||||||
char attributeLength = (char)
|
char attributeLength = (char)
|
||||||
(((bytes[offset + 2] & 0xFF) << 8) | (bytes[offset + 3] & 0xFF));
|
(((bytes[offset + 2] & 0xFF) << 8) | (bytes[offset + 3] & 0xFF));
|
||||||
|
|
||||||
if(attributeLength > bytes.length - offset )
|
if (attributeLength > bytes.length - offset )
|
||||||
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
||||||
"Could not decode the specified binary array.");
|
"Could not decode the specified binary array.");
|
||||||
|
|
||||||
@ -130,9 +130,9 @@ public class AttributeDecoder
|
|||||||
case Attribute.USE_CANDIDATE:
|
case Attribute.USE_CANDIDATE:
|
||||||
decodedAttribute = new UseCandidateAttribute(); break;
|
decodedAttribute = new UseCandidateAttribute(); break;
|
||||||
case Attribute.REQUESTED_ADDRESS_FAMILY:
|
case Attribute.REQUESTED_ADDRESS_FAMILY:
|
||||||
decodedAttribute = new RequestedAddressFamilyAttribute(); break;
|
decodedAttribute = new RequestedAddressFamilyAttribute(); break;
|
||||||
case Attribute.CONNECTION_ID:
|
case Attribute.CONNECTION_ID:
|
||||||
decodedAttribute = new ConnectionIdAttribute(); break;
|
decodedAttribute = new ConnectionIdAttribute(); break;
|
||||||
//According to rfc3489 we should silently ignore unknown attributes.
|
//According to rfc3489 we should silently ignore unknown attributes.
|
||||||
default: decodedAttribute
|
default: decodedAttribute
|
||||||
= new OptionalAttribute( Attribute.UNKNOWN_OPTIONAL_ATTRIBUTE);
|
= new OptionalAttribute( Attribute.UNKNOWN_OPTIONAL_ATTRIBUTE);
|
||||||
|
|||||||
@ -624,14 +624,14 @@ public class AttributeFactory
|
|||||||
public static RequestedAddressFamilyAttribute
|
public static RequestedAddressFamilyAttribute
|
||||||
createRequestedAddressFamilyAttribute(char family)
|
createRequestedAddressFamilyAttribute(char family)
|
||||||
{
|
{
|
||||||
RequestedAddressFamilyAttribute attribute
|
RequestedAddressFamilyAttribute attribute
|
||||||
= new RequestedAddressFamilyAttribute();
|
= new RequestedAddressFamilyAttribute();
|
||||||
|
|
||||||
boolean isSet = attribute.setFamily(family);
|
boolean isSet = attribute.setFamily(family);
|
||||||
if(!isSet)
|
if (!isSet)
|
||||||
{
|
{
|
||||||
attribute = null;
|
attribute = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return attribute;
|
return attribute;
|
||||||
}
|
}
|
||||||
@ -644,8 +644,8 @@ public class AttributeFactory
|
|||||||
*/
|
*/
|
||||||
public static ConnectionIdAttribute createConnectionIdAttribute(
|
public static ConnectionIdAttribute createConnectionIdAttribute(
|
||||||
int connectionIdValue)
|
int connectionIdValue)
|
||||||
{
|
{
|
||||||
ConnectionIdAttribute attribute = new ConnectionIdAttribute();
|
ConnectionIdAttribute attribute = new ConnectionIdAttribute();
|
||||||
|
|
||||||
attribute.setConnectionIdValue(connectionIdValue);
|
attribute.setConnectionIdValue(connectionIdValue);
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,7 @@ public class ChannelNumberAttribute extends Attribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 4)
|
if (length != 4)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid");
|
throw new StunException("length invalid");
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ public class ChannelNumberAttribute extends Attribute
|
|||||||
*/
|
*/
|
||||||
public static boolean isValidRange(char channelNo)
|
public static boolean isValidRange(char channelNo)
|
||||||
{
|
{
|
||||||
if(channelNo >= 0x4000)
|
if (channelNo >= 0x4000)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public class ConnectionIdAttribute
|
|||||||
*/
|
*/
|
||||||
protected ConnectionIdAttribute()
|
protected ConnectionIdAttribute()
|
||||||
{
|
{
|
||||||
super(CONNECTION_ID);
|
super(CONNECTION_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +58,7 @@ public class ConnectionIdAttribute
|
|||||||
@Override
|
@Override
|
||||||
public char getDataLength()
|
public char getDataLength()
|
||||||
{
|
{
|
||||||
return DATA_LENGTH;
|
return DATA_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +70,7 @@ public class ConnectionIdAttribute
|
|||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +82,7 @@ public class ConnectionIdAttribute
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if (! (obj instanceof ConnectionIdAttribute))
|
if (! (obj instanceof ConnectionIdAttribute))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (obj == this)
|
if (obj == this)
|
||||||
@ -106,7 +106,7 @@ public class ConnectionIdAttribute
|
|||||||
@Override
|
@Override
|
||||||
public byte[] encode()
|
public byte[] encode()
|
||||||
{
|
{
|
||||||
byte binValue[] = new byte[HEADER_LENGTH + DATA_LENGTH];
|
byte binValue[] = new byte[HEADER_LENGTH + DATA_LENGTH];
|
||||||
|
|
||||||
//Type
|
//Type
|
||||||
binValue[0] = (byte)(getAttributeType() >> 8);
|
binValue[0] = (byte)(getAttributeType() >> 8);
|
||||||
@ -135,9 +135,9 @@ public class ConnectionIdAttribute
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != DATA_LENGTH)
|
if (length != DATA_LENGTH)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid: " + length);
|
throw new StunException("length invalid: " + length);
|
||||||
}
|
}
|
||||||
@ -168,8 +168,8 @@ public class ConnectionIdAttribute
|
|||||||
* @param connectionIdValue the connection Id value.
|
* @param connectionIdValue the connection Id value.
|
||||||
*/
|
*/
|
||||||
public void setConnectionIdValue(int connectionIdValue)
|
public void setConnectionIdValue(int connectionIdValue)
|
||||||
{
|
{
|
||||||
this.connectionIdValue = connectionIdValue;
|
this.connectionIdValue = connectionIdValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,7 +112,7 @@ public class DontFragmentAttribute extends Attribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 0)
|
if (length != 0)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid");
|
throw new StunException("length invalid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -288,7 +288,7 @@ public class ErrorCodeAttribute extends Attribute
|
|||||||
public void setErrorClass(byte errorClass)
|
public void setErrorClass(byte errorClass)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(errorClass < 0 || errorClass > 99)
|
if (errorClass < 0 || errorClass > 99)
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
errorClass + " is not a valid error number!");
|
errorClass + " is not a valid error number!");
|
||||||
this.errorClass = errorClass;
|
this.errorClass = errorClass;
|
||||||
@ -415,7 +415,7 @@ public class ErrorCodeAttribute extends Attribute
|
|||||||
*/
|
*/
|
||||||
public String getReasonPhrase()
|
public String getReasonPhrase()
|
||||||
{
|
{
|
||||||
if(reasonPhrase == null)
|
if (reasonPhrase == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new String(reasonPhrase);
|
return new String(reasonPhrase);
|
||||||
@ -472,7 +472,7 @@ public class ErrorCodeAttribute extends Attribute
|
|||||||
binValue[6] = getErrorClass();
|
binValue[6] = getErrorClass();
|
||||||
binValue[7] = getErrorNumber();
|
binValue[7] = getErrorNumber();
|
||||||
|
|
||||||
if(reasonPhrase != null)
|
if (reasonPhrase != null)
|
||||||
System.arraycopy(reasonPhrase, 0, binValue, 8, reasonPhrase.length);
|
System.arraycopy(reasonPhrase, 0, binValue, 8, reasonPhrase.length);
|
||||||
|
|
||||||
return binValue;
|
return binValue;
|
||||||
|
|||||||
@ -132,7 +132,7 @@ public class EvenPortAttribute extends Attribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 4)
|
if (length != 4)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid");
|
throw new StunException("length invalid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -212,7 +212,7 @@ public class FingerprintAttribute
|
|||||||
char length)
|
char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 4)
|
if (length != 4)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid");
|
throw new StunException("length invalid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,14 +125,14 @@ public abstract class IceControlAttribute
|
|||||||
*/
|
*/
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if(!(obj instanceof IceControlAttribute))
|
if (!(obj instanceof IceControlAttribute))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
IceControlAttribute iceControlAtt = (IceControlAttribute)obj;
|
IceControlAttribute iceControlAtt = (IceControlAttribute)obj;
|
||||||
if(iceControlAtt.getAttributeType() != getAttributeType()
|
if (iceControlAtt.getAttributeType() != getAttributeType()
|
||||||
|| iceControlAtt.isControlling != isControlling
|
|| iceControlAtt.isControlling != isControlling
|
||||||
|| iceControlAtt.getDataLength() != DATA_LENGTH_ICE_CONTROL
|
|| iceControlAtt.getDataLength() != DATA_LENGTH_ICE_CONTROL
|
||||||
|| getTieBreaker() != iceControlAtt.getTieBreaker())
|
|| getTieBreaker() != iceControlAtt.getTieBreaker())
|
||||||
|
|||||||
@ -138,7 +138,7 @@ public class LifetimeAttribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 4)
|
if (length != 4)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid");
|
throw new StunException("length invalid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,7 +138,7 @@ public class MagicCookieAttribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 4)
|
if (length != 4)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid");
|
throw new StunException("length invalid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,7 +134,7 @@ public class OptionalAttribute
|
|||||||
*/
|
*/
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if(! (obj instanceof OptionalAttribute) )
|
if (! (obj instanceof OptionalAttribute) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@ -174,7 +174,7 @@ public class PriorityAttribute
|
|||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
/* Priority must be between 1 and (2^31 - 1) */
|
/* Priority must be between 1 and (2^31 - 1) */
|
||||||
if(priority <= 0 || priority > 0x7FFFFFFFL)
|
if (priority <= 0 || priority > 0x7FFFFFFFL)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Priority must be " +
|
throw new IllegalArgumentException("Priority must be " +
|
||||||
"between 0 and (2**31 - 1)");
|
"between 0 and (2**31 - 1)");
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class RequestedAddressFamilyAttribute extends Attribute
|
|||||||
*/
|
*/
|
||||||
protected RequestedAddressFamilyAttribute()
|
protected RequestedAddressFamilyAttribute()
|
||||||
{
|
{
|
||||||
super(REQUESTED_ADDRESS_FAMILY);
|
super(REQUESTED_ADDRESS_FAMILY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public class RequestedAddressFamilyAttribute extends Attribute
|
|||||||
@Override
|
@Override
|
||||||
public char getDataLength()
|
public char getDataLength()
|
||||||
{
|
{
|
||||||
return DATA_LENGTH;
|
return DATA_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ public class RequestedAddressFamilyAttribute extends Attribute
|
|||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +90,7 @@ public class RequestedAddressFamilyAttribute extends Attribute
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if (! (obj instanceof RequestedAddressFamilyAttribute))
|
if (! (obj instanceof RequestedAddressFamilyAttribute))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (obj == this)
|
if (obj == this)
|
||||||
@ -142,16 +142,16 @@ public class RequestedAddressFamilyAttribute extends Attribute
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != DATA_LENGTH)
|
if (length != DATA_LENGTH)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid: " + length);
|
throw new StunException("length invalid: " + length);
|
||||||
}
|
}
|
||||||
|
|
||||||
family = (char)(attributeValue[offset] & 0xff);
|
family = (char)(attributeValue[offset] & 0xff);
|
||||||
|
|
||||||
if(family != IPv4 && family != IPv6)
|
if (family != IPv4 && family != IPv6)
|
||||||
{
|
{
|
||||||
// instead throw TurnException
|
// instead throw TurnException
|
||||||
throw new StunException("invalid family value: " + family);
|
throw new StunException("invalid family value: " + family);
|
||||||
@ -173,8 +173,8 @@ public class RequestedAddressFamilyAttribute extends Attribute
|
|||||||
* @return true if argument is IPv4 or IPv6 otherwise false
|
* @return true if argument is IPv4 or IPv6 otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean setFamily(char family)
|
public boolean setFamily(char family)
|
||||||
{
|
{
|
||||||
if(family == IPv4 || family == IPv6)
|
if (family == IPv4 || family == IPv6)
|
||||||
{
|
{
|
||||||
this.family = family;
|
this.family = family;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -147,7 +147,7 @@ public class RequestedTransportAttribute extends Attribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 4)
|
if (length != 4)
|
||||||
{
|
{
|
||||||
throw new StunException("length invalid");
|
throw new StunException("length invalid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class ReservationTokenAttribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(length != 8)
|
if (length != 8)
|
||||||
{
|
{
|
||||||
throw new StunException("Length mismatch!");
|
throw new StunException("Length mismatch!");
|
||||||
}
|
}
|
||||||
@ -189,12 +189,12 @@ public class ReservationTokenAttribute
|
|||||||
private static void generateReservationTokenAttribute(
|
private static void generateReservationTokenAttribute(
|
||||||
ReservationTokenAttribute token, int nb)
|
ReservationTokenAttribute token, int nb)
|
||||||
{
|
{
|
||||||
long left = System.currentTimeMillis();// the first nb/2 bytes of the
|
long left = System.currentTimeMillis(); // the first nb/2 bytes of the
|
||||||
// token
|
// token
|
||||||
long right = random.nextLong();// the last nb/2 bytes of the token
|
long right = random.nextLong(); // the last nb/2 bytes of the token
|
||||||
int b = nb / 2;
|
int b = nb / 2;
|
||||||
|
|
||||||
for(int i = 0; i < b; i++)
|
for (int i = 0; i < b; i++)
|
||||||
{
|
{
|
||||||
token.reservationToken[i] = (byte)((left >> (i * 8)) & 0xFFL);
|
token.reservationToken[i] = (byte)((left >> (i * 8)) & 0xFFL);
|
||||||
token.reservationToken[i + b] = (byte)((right >> (i * 8)) & 0xFFL);
|
token.reservationToken[i + b] = (byte)((right >> (i * 8)) & 0xFFL);
|
||||||
|
|||||||
@ -84,7 +84,7 @@ public class UnknownAttributesAttribute extends Attribute
|
|||||||
{
|
{
|
||||||
char len = (char)unknownAttributes.size();
|
char len = (char)unknownAttributes.size();
|
||||||
|
|
||||||
if( (len % 2 ) != 0 )
|
if ( (len % 2 ) != 0 )
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
return (char)(len * 2);
|
return (char)(len * 2);
|
||||||
@ -99,7 +99,7 @@ public class UnknownAttributesAttribute extends Attribute
|
|||||||
{
|
{
|
||||||
//some attributes may be repeated for padding
|
//some attributes may be repeated for padding
|
||||||
//(packet length should be divisable by 4)
|
//(packet length should be divisable by 4)
|
||||||
if(!contains(attributeID))
|
if (!contains(attributeID))
|
||||||
unknownAttributes.add(attributeID);
|
unknownAttributes.add(attributeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ public class UnknownAttributesAttribute extends Attribute
|
|||||||
// If the number of unknown attributes is an odd number, one of the
|
// If the number of unknown attributes is an odd number, one of the
|
||||||
// attributes MUST be repeated in the list, so that the total length of
|
// attributes MUST be repeated in the list, so that the total length of
|
||||||
// the list is a multiple of 4 bytes.
|
// the list is a multiple of 4 bytes.
|
||||||
if(offset < binValue.length)
|
if (offset < binValue.length)
|
||||||
{
|
{
|
||||||
char att = getAttribute(0);
|
char att = getAttribute(0);
|
||||||
binValue[offset++] = (byte) (att >> 8);
|
binValue[offset++] = (byte) (att >> 8);
|
||||||
@ -221,12 +221,12 @@ public class UnknownAttributesAttribute extends Attribute
|
|||||||
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
void decodeAttributeBody(byte[] attributeValue, char offset, char length)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if( (length % 2 ) != 0)
|
if ( (length % 2 ) != 0)
|
||||||
throw new StunException("Attribute IDs are 2 bytes long and the "
|
throw new StunException("Attribute IDs are 2 bytes long and the "
|
||||||
+ "passed binary array has an odd length " +
|
+ "passed binary array has an odd length " +
|
||||||
"value.");
|
"value.");
|
||||||
char originalOffset = offset;
|
char originalOffset = offset;
|
||||||
for(int i = offset; i < originalOffset + length; i += 2)
|
for (int i = offset; i < originalOffset + length; i += 2)
|
||||||
{
|
{
|
||||||
char attributeID = (char) (((attributeValue[offset++] & 0xFF) << 8)
|
char attributeID = (char) (((attributeValue[offset++] & 0xFF) << 8)
|
||||||
| (attributeValue[offset++] & 0xFF));
|
| (attributeValue[offset++] & 0xFF));
|
||||||
|
|||||||
@ -89,14 +89,14 @@ public class UseCandidateAttribute
|
|||||||
*/
|
*/
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if(!(obj instanceof UseCandidateAttribute))
|
if (!(obj instanceof UseCandidateAttribute))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
UseCandidateAttribute useCandidateAtt = (UseCandidateAttribute)obj;
|
UseCandidateAttribute useCandidateAtt = (UseCandidateAttribute)obj;
|
||||||
if(useCandidateAtt.getAttributeType() != getAttributeType()
|
if (useCandidateAtt.getAttributeType() != getAttributeType()
|
||||||
|| useCandidateAtt.getDataLength() != getDataLength())
|
|| useCandidateAtt.getDataLength() != getDataLength())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ public class XorMappedAddressAttribute
|
|||||||
|
|
||||||
port ^= portModifier;
|
port ^= portModifier;
|
||||||
|
|
||||||
for(int i = 0; i < addressBytes.length; i++)
|
for (int i = 0; i < addressBytes.length; i++)
|
||||||
addressBytes[i] ^= transactionID[i];
|
addressBytes[i] ^= transactionID[i];
|
||||||
|
|
||||||
TransportAddress xoredAdd;
|
TransportAddress xoredAdd;
|
||||||
|
|||||||
@ -438,17 +438,17 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
/* Google Talk priority is in range 0 - 1, we multiply this by 1000
|
/* Google Talk priority is in range 0 - 1, we multiply this by 1000
|
||||||
* to have a long rather than float
|
* to have a long rather than float
|
||||||
*/
|
*/
|
||||||
if(candidateType == CandidateType.HOST_CANDIDATE)
|
if (candidateType == CandidateType.HOST_CANDIDATE)
|
||||||
{
|
{
|
||||||
priority += 0.95 * 1000 -
|
priority += 0.95 * 1000 -
|
||||||
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
|
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
|
||||||
}
|
}
|
||||||
else if(candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
|
else if (candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
|
||||||
{
|
{
|
||||||
priority += (long)(0.9 * 1000) -
|
priority += (long)(0.9 * 1000) -
|
||||||
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
|
(this.getBase().getTransport() == Transport.TCP ? 200 : 0);
|
||||||
}
|
}
|
||||||
else if(candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
|
else if (candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
|
||||||
{
|
{
|
||||||
priority += (long)(0.9 * 1000);
|
priority += (long)(0.9 * 1000);
|
||||||
}
|
}
|
||||||
@ -462,9 +462,9 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
InetAddress addr = getTransportAddress().getAddress();
|
InetAddress addr = getTransportAddress().getAddress();
|
||||||
|
|
||||||
// IPv6 has better priority than IPv4
|
// IPv6 has better priority than IPv4
|
||||||
if(addr instanceof Inet6Address)
|
if (addr instanceof Inet6Address)
|
||||||
{
|
{
|
||||||
if(addr.isLinkLocalAddress())
|
if (addr.isLinkLocalAddress())
|
||||||
{
|
{
|
||||||
priority += 40;
|
priority += 40;
|
||||||
}
|
}
|
||||||
@ -499,15 +499,15 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
{
|
{
|
||||||
int typePreference;
|
int typePreference;
|
||||||
|
|
||||||
if(candidateType == CandidateType.HOST_CANDIDATE)
|
if (candidateType == CandidateType.HOST_CANDIDATE)
|
||||||
{
|
{
|
||||||
typePreference = MAX_TYPE_PREFERENCE; // 126
|
typePreference = MAX_TYPE_PREFERENCE; // 126
|
||||||
}
|
}
|
||||||
else if(candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
|
else if (candidateType == CandidateType.PEER_REFLEXIVE_CANDIDATE)
|
||||||
{
|
{
|
||||||
typePreference = 110;
|
typePreference = 110;
|
||||||
}
|
}
|
||||||
else if(candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
|
else if (candidateType == CandidateType.SERVER_REFLEXIVE_CANDIDATE)
|
||||||
{
|
{
|
||||||
typePreference = 100;
|
typePreference = 100;
|
||||||
}
|
}
|
||||||
@ -540,13 +540,13 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
{
|
{
|
||||||
//The ICE spec says: When there is only a single IP address, this value
|
//The ICE spec says: When there is only a single IP address, this value
|
||||||
//SHOULD be set to.
|
//SHOULD be set to.
|
||||||
if(getParentComponent().countLocalHostCandidates() < 2)
|
if (getParentComponent().countLocalHostCandidates() < 2)
|
||||||
return MAX_LOCAL_PREFERENCE;
|
return MAX_LOCAL_PREFERENCE;
|
||||||
|
|
||||||
//The ICE spec also says: Furthermore, if an agent is multi-homed and
|
//The ICE spec also says: Furthermore, if an agent is multi-homed and
|
||||||
//has multiple IP addresses, the local preference for host candidates
|
//has multiple IP addresses, the local preference for host candidates
|
||||||
//from a VPN interface SHOULD have a priority of 0.
|
//from a VPN interface SHOULD have a priority of 0.
|
||||||
if(isVirtual())
|
if (isVirtual())
|
||||||
return MIN_LOCAL_PREFERENCE;
|
return MIN_LOCAL_PREFERENCE;
|
||||||
|
|
||||||
InetAddress addr = getTransportAddress().getAddress();
|
InetAddress addr = getTransportAddress().getAddress();
|
||||||
@ -556,10 +556,10 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
//Johnnie seems to think.
|
//Johnnie seems to think.
|
||||||
|
|
||||||
//prefer IPv6 to IPv4
|
//prefer IPv6 to IPv4
|
||||||
if(addr instanceof Inet6Address)
|
if (addr instanceof Inet6Address)
|
||||||
{
|
{
|
||||||
//prefer link local addresses to global ones
|
//prefer link local addresses to global ones
|
||||||
if(addr.isLinkLocalAddress())
|
if (addr.isLinkLocalAddress())
|
||||||
return 30;
|
return 30;
|
||||||
else
|
else
|
||||||
return 40;
|
return 40;
|
||||||
@ -719,7 +719,7 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
*/
|
*/
|
||||||
public TransportAddress getRelatedAddress()
|
public TransportAddress getRelatedAddress()
|
||||||
{
|
{
|
||||||
if(getRelatedCandidate() != null)
|
if (getRelatedCandidate() != null)
|
||||||
{
|
{
|
||||||
return getRelatedCandidate().getTransportAddress();
|
return getRelatedCandidate().getTransportAddress();
|
||||||
}
|
}
|
||||||
@ -770,7 +770,7 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
|
|
||||||
TransportAddress relAddr = getRelatedAddress();
|
TransportAddress relAddr = getRelatedAddress();
|
||||||
|
|
||||||
if(relAddr != null)
|
if (relAddr != null)
|
||||||
{
|
{
|
||||||
buff.append(" raddr ").append(relAddr.getHostAddress());
|
buff.append(" raddr ").append(relAddr.getHostAddress());
|
||||||
buff.append(" rport ").append(relAddr.getPort());
|
buff.append(" rport ").append(relAddr.getPort());
|
||||||
@ -873,19 +873,19 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
switch (getType())
|
switch (getType())
|
||||||
{
|
{
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
case SERVER_REFLEXIVE_CANDIDATE:
|
||||||
if(getBase() != null)
|
if (getBase() != null)
|
||||||
{
|
{
|
||||||
return getBase().getHostAddress();
|
return getBase().getHostAddress();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
case PEER_REFLEXIVE_CANDIDATE:
|
||||||
if(getBase() != null)
|
if (getBase() != null)
|
||||||
{
|
{
|
||||||
return getBase().getHostAddress();
|
return getBase().getHostAddress();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RELAYED_CANDIDATE:
|
case RELAYED_CANDIDATE:
|
||||||
if(getRelatedCandidate() != null)
|
if (getRelatedCandidate() != null)
|
||||||
{
|
{
|
||||||
return getRelatedCandidate().getHostAddress();
|
return getRelatedCandidate().getHostAddress();
|
||||||
}
|
}
|
||||||
@ -912,7 +912,7 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
return getTransportAddress();
|
return getTransportAddress();
|
||||||
case RELAYED_CANDIDATE:
|
case RELAYED_CANDIDATE:
|
||||||
// Corresponding to getMappedAddress();
|
// Corresponding to getMappedAddress();
|
||||||
if(getRelatedCandidate() != null)
|
if (getRelatedCandidate() != null)
|
||||||
{
|
{
|
||||||
return getRelatedCandidate().getReflexiveAddress();
|
return getRelatedCandidate().getReflexiveAddress();
|
||||||
}
|
}
|
||||||
@ -965,19 +965,19 @@ public abstract class Candidate<T extends Candidate<?>>
|
|||||||
*/
|
*/
|
||||||
public T getRelatedCandidate()
|
public T getRelatedCandidate()
|
||||||
{
|
{
|
||||||
if(this.relatedCandidate == null)
|
if (this.relatedCandidate == null)
|
||||||
{
|
{
|
||||||
TransportAddress relatedAddress = null;
|
TransportAddress relatedAddress = null;
|
||||||
switch (getType())
|
switch (getType())
|
||||||
{
|
{
|
||||||
case SERVER_REFLEXIVE_CANDIDATE:
|
case SERVER_REFLEXIVE_CANDIDATE:
|
||||||
if(getBase() != null)
|
if (getBase() != null)
|
||||||
{
|
{
|
||||||
relatedAddress = getBase().getTransportAddress();
|
relatedAddress = getBase().getTransportAddress();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PEER_REFLEXIVE_CANDIDATE:
|
case PEER_REFLEXIVE_CANDIDATE:
|
||||||
if(getBase() != null)
|
if (getBase() != null)
|
||||||
{
|
{
|
||||||
relatedAddress = getBase().getTransportAddress();
|
relatedAddress = getBase().getTransportAddress();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,25 +122,25 @@ public enum CandidateExtendedType
|
|||||||
public static CandidateExtendedType parse(String extendedTypeName)
|
public static CandidateExtendedType parse(String extendedTypeName)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(HOST_CANDIDATE.toString().equals(extendedTypeName))
|
if (HOST_CANDIDATE.toString().equals(extendedTypeName))
|
||||||
return HOST_CANDIDATE;
|
return HOST_CANDIDATE;
|
||||||
else if(UPNP_CANDIDATE.toString().equals(extendedTypeName))
|
else if (UPNP_CANDIDATE.toString().equals(extendedTypeName))
|
||||||
return UPNP_CANDIDATE;
|
return UPNP_CANDIDATE;
|
||||||
else if(STUN_PEER_REFLEXIVE_CANDIDATE.toString().equals(
|
else if (STUN_PEER_REFLEXIVE_CANDIDATE.toString().equals(
|
||||||
extendedTypeName))
|
extendedTypeName))
|
||||||
return STUN_PEER_REFLEXIVE_CANDIDATE;
|
return STUN_PEER_REFLEXIVE_CANDIDATE;
|
||||||
else if(STUN_SERVER_REFLEXIVE_CANDIDATE.toString().equals(
|
else if (STUN_SERVER_REFLEXIVE_CANDIDATE.toString().equals(
|
||||||
extendedTypeName))
|
extendedTypeName))
|
||||||
return STUN_SERVER_REFLEXIVE_CANDIDATE;
|
return STUN_SERVER_REFLEXIVE_CANDIDATE;
|
||||||
else if(TURN_RELAYED_CANDIDATE.toString().equals(extendedTypeName))
|
else if (TURN_RELAYED_CANDIDATE.toString().equals(extendedTypeName))
|
||||||
return TURN_RELAYED_CANDIDATE;
|
return TURN_RELAYED_CANDIDATE;
|
||||||
else if(GOOGLE_TURN_RELAYED_CANDIDATE.toString().equals(
|
else if (GOOGLE_TURN_RELAYED_CANDIDATE.toString().equals(
|
||||||
extendedTypeName))
|
extendedTypeName))
|
||||||
return GOOGLE_TURN_RELAYED_CANDIDATE;
|
return GOOGLE_TURN_RELAYED_CANDIDATE;
|
||||||
else if(GOOGLE_TCP_TURN_RELAYED_CANDIDATE.toString().equals(
|
else if (GOOGLE_TCP_TURN_RELAYED_CANDIDATE.toString().equals(
|
||||||
extendedTypeName))
|
extendedTypeName))
|
||||||
return GOOGLE_TCP_TURN_RELAYED_CANDIDATE;
|
return GOOGLE_TCP_TURN_RELAYED_CANDIDATE;
|
||||||
else if(JINGLE_NODE_CANDIDATE.toString().equals(extendedTypeName))
|
else if (JINGLE_NODE_CANDIDATE.toString().equals(extendedTypeName))
|
||||||
return JINGLE_NODE_CANDIDATE;
|
return JINGLE_NODE_CANDIDATE;
|
||||||
|
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|||||||
@ -123,23 +123,23 @@ public enum CandidateType
|
|||||||
public static CandidateType parse(String candidateTypeName)
|
public static CandidateType parse(String candidateTypeName)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(PEER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
|
if (PEER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
|
||||||
return PEER_REFLEXIVE_CANDIDATE;
|
return PEER_REFLEXIVE_CANDIDATE;
|
||||||
|
|
||||||
if(SERVER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
|
if (SERVER_REFLEXIVE_CANDIDATE.toString().equals(candidateTypeName))
|
||||||
return SERVER_REFLEXIVE_CANDIDATE;
|
return SERVER_REFLEXIVE_CANDIDATE;
|
||||||
|
|
||||||
if(RELAYED_CANDIDATE.toString().equals(candidateTypeName))
|
if (RELAYED_CANDIDATE.toString().equals(candidateTypeName))
|
||||||
return RELAYED_CANDIDATE;
|
return RELAYED_CANDIDATE;
|
||||||
|
|
||||||
if(HOST_CANDIDATE.toString().equals(candidateTypeName))
|
if (HOST_CANDIDATE.toString().equals(candidateTypeName))
|
||||||
return HOST_CANDIDATE;
|
return HOST_CANDIDATE;
|
||||||
|
|
||||||
// old name but returns the standard name
|
// old name but returns the standard name
|
||||||
if(STUN_CANDIDATE.toString().equals(candidateTypeName))
|
if (STUN_CANDIDATE.toString().equals(candidateTypeName))
|
||||||
return SERVER_REFLEXIVE_CANDIDATE;
|
return SERVER_REFLEXIVE_CANDIDATE;
|
||||||
|
|
||||||
if(LOCAL_CANDIDATE.toString().equals(candidateTypeName))
|
if (LOCAL_CANDIDATE.toString().equals(candidateTypeName))
|
||||||
return HOST_CANDIDATE;
|
return HOST_CANDIDATE;
|
||||||
|
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|||||||
@ -135,7 +135,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
synchronized(triggeredCheckQueue)
|
synchronized(triggeredCheckQueue)
|
||||||
{
|
{
|
||||||
if(!triggeredCheckQueue.contains(pair))
|
if (!triggeredCheckQueue.contains(pair))
|
||||||
{
|
{
|
||||||
triggeredCheckQueue.add(pair);
|
triggeredCheckQueue.add(pair);
|
||||||
pair.setStateWaiting();
|
pair.setStateWaiting();
|
||||||
@ -154,7 +154,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
synchronized(triggeredCheckQueue)
|
synchronized(triggeredCheckQueue)
|
||||||
{
|
{
|
||||||
if(triggeredCheckQueue.size() > 0)
|
if (triggeredCheckQueue.size() > 0)
|
||||||
return triggeredCheckQueue.remove(0);
|
return triggeredCheckQueue.remove(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -182,7 +182,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
if (pair.getState() == CandidatePairState.WAITING)
|
if (pair.getState() == CandidatePairState.WAITING)
|
||||||
{
|
{
|
||||||
if(highestPriorityPair == null
|
if (highestPriorityPair == null
|
||||||
|| pair.getPriority() > highestPriorityPair.getPriority())
|
|| pair.getPriority() > highestPriorityPair.getPriority())
|
||||||
{
|
{
|
||||||
highestPriorityPair = pair;
|
highestPriorityPair = pair;
|
||||||
@ -190,14 +190,14 @@ public class CheckList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(highestPriorityPair != null)
|
if (highestPriorityPair != null)
|
||||||
return highestPriorityPair;
|
return highestPriorityPair;
|
||||||
|
|
||||||
for (CandidatePair pair : this)
|
for (CandidatePair pair : this)
|
||||||
{
|
{
|
||||||
if (pair.getState() == CandidatePairState.FROZEN)
|
if (pair.getState() == CandidatePairState.FROZEN)
|
||||||
{
|
{
|
||||||
if(highestPriorityPair == null
|
if (highestPriorityPair == null
|
||||||
|| pair.getPriority() > highestPriorityPair.getPriority())
|
|| pair.getPriority() > highestPriorityPair.getPriority())
|
||||||
{
|
{
|
||||||
highestPriorityPair = pair;
|
highestPriorityPair = pair;
|
||||||
@ -319,14 +319,14 @@ public class CheckList
|
|||||||
Map<String, CandidatePair> pairsToWait = new Hashtable<>();
|
Map<String, CandidatePair> pairsToWait = new Hashtable<>();
|
||||||
|
|
||||||
//first, determine the pairs that we'd need to put in the waiting state.
|
//first, determine the pairs that we'd need to put in the waiting state.
|
||||||
for(CandidatePair pair : this)
|
for (CandidatePair pair : this)
|
||||||
{
|
{
|
||||||
//we need to check whether the pair is already in the wait list. if
|
//we need to check whether the pair is already in the wait list. if
|
||||||
//so we'll compare it with this one and determine which of the two
|
//so we'll compare it with this one and determine which of the two
|
||||||
//needs to stay.
|
//needs to stay.
|
||||||
CandidatePair prevPair = pairsToWait.get(pair.getFoundation());
|
CandidatePair prevPair = pairsToWait.get(pair.getFoundation());
|
||||||
|
|
||||||
if(prevPair == null)
|
if (prevPair == null)
|
||||||
{
|
{
|
||||||
//first pair with this foundation.
|
//first pair with this foundation.
|
||||||
pairsToWait.put(pair.getFoundation(), pair);
|
pairsToWait.put(pair.getFoundation(), pair);
|
||||||
@ -336,9 +336,9 @@ public class CheckList
|
|||||||
//we already have a pair with the same foundation. determine which
|
//we already have a pair with the same foundation. determine which
|
||||||
//of the two has the lower component id and higher priority and
|
//of the two has the lower component id and higher priority and
|
||||||
//keep that one in the list.
|
//keep that one in the list.
|
||||||
if( prevPair.getParentComponent() == pair.getParentComponent())
|
if ( prevPair.getParentComponent() == pair.getParentComponent())
|
||||||
{
|
{
|
||||||
if(pair.getPriority() > prevPair.getPriority())
|
if (pair.getPriority() > prevPair.getPriority())
|
||||||
{
|
{
|
||||||
//need to replace the pair in the list.
|
//need to replace the pair in the list.
|
||||||
pairsToWait.put(pair.getFoundation(), pair);
|
pairsToWait.put(pair.getFoundation(), pair);
|
||||||
@ -346,7 +346,7 @@ public class CheckList
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(pair.getParentComponent().getComponentID()
|
if (pair.getParentComponent().getComponentID()
|
||||||
< prevPair.getParentComponent().getComponentID())
|
< prevPair.getParentComponent().getComponentID())
|
||||||
{
|
{
|
||||||
//need to replace the pair in the list.
|
//need to replace the pair in the list.
|
||||||
@ -368,7 +368,7 @@ public class CheckList
|
|||||||
protected synchronized void recomputePairPriorities()
|
protected synchronized void recomputePairPriorities()
|
||||||
{
|
{
|
||||||
//first, determine the pairs that we'd need to put in the waiting state.
|
//first, determine the pairs that we'd need to put in the waiting state.
|
||||||
for(CandidatePair pair : this)
|
for (CandidatePair pair : this)
|
||||||
pair.computePriority();
|
pair.computePriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
Component cmp = nominatedPair.getParentComponent();
|
Component cmp = nominatedPair.getParentComponent();
|
||||||
|
|
||||||
if(cmp.getSelectedPair() != null)
|
if (cmp.getSelectedPair() != null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ public class CheckList
|
|||||||
cmp.setSelectedPair(nominatedPair);
|
cmp.setSelectedPair(nominatedPair);
|
||||||
|
|
||||||
Iterator<CandidatePair> pairsIter = iterator();
|
Iterator<CandidatePair> pairsIter = iterator();
|
||||||
while(pairsIter.hasNext())
|
while (pairsIter.hasNext())
|
||||||
{
|
{
|
||||||
CandidatePair pair = pairsIter.next();
|
CandidatePair pair = pairsIter.next();
|
||||||
if (pair.getParentComponent() == cmp
|
if (pair.getParentComponent() == cmp
|
||||||
@ -427,7 +427,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
Iterator<CandidatePair> triggeredPairsIter
|
Iterator<CandidatePair> triggeredPairsIter
|
||||||
= triggeredCheckQueue.iterator();
|
= triggeredCheckQueue.iterator();
|
||||||
while(triggeredPairsIter.hasNext())
|
while (triggeredPairsIter.hasNext())
|
||||||
{
|
{
|
||||||
CandidatePair pair = triggeredPairsIter.next();
|
CandidatePair pair = triggeredPairsIter.next();
|
||||||
if (pair.getParentComponent() == cmp
|
if (pair.getParentComponent() == cmp
|
||||||
@ -493,7 +493,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
synchronized(stateListeners)
|
synchronized(stateListeners)
|
||||||
{
|
{
|
||||||
if(!stateListeners.contains(l))
|
if (!stateListeners.contains(l))
|
||||||
this.stateListeners.add(l);
|
this.stateListeners.add(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,7 +532,7 @@ public class CheckList
|
|||||||
PropertyChangeEvent evt = new PropertyChangeEvent(
|
PropertyChangeEvent evt = new PropertyChangeEvent(
|
||||||
this, PROPERTY_CHECK_LIST_STATE, oldState, newState);
|
this, PROPERTY_CHECK_LIST_STATE, oldState, newState);
|
||||||
|
|
||||||
for(PropertyChangeListener l : listenersCopy)
|
for (PropertyChangeListener l : listenersCopy)
|
||||||
{
|
{
|
||||||
l.propertyChange(evt);
|
l.propertyChange(evt);
|
||||||
}
|
}
|
||||||
@ -548,7 +548,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
synchronized(checkListeners)
|
synchronized(checkListeners)
|
||||||
{
|
{
|
||||||
if(!checkListeners.contains(l))
|
if (!checkListeners.contains(l))
|
||||||
{
|
{
|
||||||
checkListeners.add(l);
|
checkListeners.add(l);
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ public class CheckList
|
|||||||
{
|
{
|
||||||
synchronized(checkListeners)
|
synchronized(checkListeners)
|
||||||
{
|
{
|
||||||
if(checkListeners.contains(l))
|
if (checkListeners.contains(l))
|
||||||
{
|
{
|
||||||
checkListeners.remove(l);
|
checkListeners.remove(l);
|
||||||
}
|
}
|
||||||
@ -587,7 +587,7 @@ public class CheckList
|
|||||||
PropertyChangeEvent evt = new PropertyChangeEvent(
|
PropertyChangeEvent evt = new PropertyChangeEvent(
|
||||||
this, PROPERTY_CHECK_LIST_CHECKS, false, true);
|
this, PROPERTY_CHECK_LIST_CHECKS, false, true);
|
||||||
|
|
||||||
for(PropertyChangeListener l : listenersCopy)
|
for (PropertyChangeListener l : listenersCopy)
|
||||||
{
|
{
|
||||||
l.propertyChange(evt);
|
l.propertyChange(evt);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -468,15 +468,18 @@ public class Component
|
|||||||
* since those candidates aren't added to the candidate list even
|
* since those candidates aren't added to the candidate list even
|
||||||
* though the pair is added to the check list).
|
* though the pair is added to the check list).
|
||||||
*/
|
*/
|
||||||
CandidatePair existingPair = streamCheckList.findPairMatching(pair.getLocalCandidate(), pair.getRemoteCandidate());
|
CandidatePair existingPair
|
||||||
if (existingPair != null) {
|
= streamCheckList.findPairMatching(pair.getLocalCandidate(), pair.getRemoteCandidate());
|
||||||
|
if (existingPair != null)
|
||||||
|
{
|
||||||
logger.info("existing Pair updated: " +
|
logger.info("existing Pair updated: " +
|
||||||
existingPair.toShortString() +
|
existingPair.toShortString() +
|
||||||
" to " + pair.toShortString() + ".");
|
" to " + pair.toShortString() + ".");
|
||||||
existingPair.setRemoteCandidate(pair.getRemoteCandidate());
|
existingPair.setRemoteCandidate(pair.getRemoteCandidate());
|
||||||
existingPair.computePriority();
|
existingPair.computePriority();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
streamCheckList.add(pair);
|
streamCheckList.add(pair);
|
||||||
logger.info("new Pair added: " + pair.toShortString()
|
logger.info("new Pair added: " + pair.toShortString()
|
||||||
+ ".");
|
+ ".");
|
||||||
|
|||||||
@ -124,14 +124,14 @@ class ConnectivityCheckServer
|
|||||||
UsernameAttribute uname = (UsernameAttribute)request
|
UsernameAttribute uname = (UsernameAttribute)request
|
||||||
.getAttribute(Attribute.USERNAME);
|
.getAttribute(Attribute.USERNAME);
|
||||||
|
|
||||||
if( uname == null
|
if ( uname == null
|
||||||
|| !checkLocalUserName(new String(uname.getUsername())))
|
|| !checkLocalUserName(new String(uname.getUsername())))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//detect role conflicts
|
//detect role conflicts
|
||||||
if( ( parentAgent.isControlling()
|
if ( ( parentAgent.isControlling()
|
||||||
&& request.containsAttribute(Attribute.ICE_CONTROLLING))
|
&& request.containsAttribute(Attribute.ICE_CONTROLLING))
|
||||||
|| ( ! parentAgent.isControlling()
|
|| ( ! parentAgent.isControlling()
|
||||||
&& request.containsAttribute(Attribute.ICE_CONTROLLED)))
|
&& request.containsAttribute(Attribute.ICE_CONTROLLED)))
|
||||||
@ -214,7 +214,7 @@ class ConnectivityCheckServer
|
|||||||
//apply tie-breaking
|
//apply tie-breaking
|
||||||
|
|
||||||
//extract priority
|
//extract priority
|
||||||
if(priorityAttr == null)
|
if (priorityAttr == null)
|
||||||
{
|
{
|
||||||
logger.debug(() -> "Received a connectivity check with"
|
logger.debug(() -> "Received a connectivity check with"
|
||||||
+ "no PRIORITY attribute. Discarding.");
|
+ "no PRIORITY attribute. Discarding.");
|
||||||
@ -255,7 +255,8 @@ class ConnectivityCheckServer
|
|||||||
final boolean bothControlledConflict = !selfIceControlling &&
|
final boolean bothControlledConflict = !selfIceControlling &&
|
||||||
req.containsAttribute(Attribute.ICE_CONTROLLED);
|
req.containsAttribute(Attribute.ICE_CONTROLLED);
|
||||||
|
|
||||||
if (!(bothControllingConflict || bothControlledConflict)) {
|
if (!(bothControllingConflict || bothControlledConflict))
|
||||||
|
{
|
||||||
// we don't have a role conflict
|
// we don't have a role conflict
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -379,7 +380,7 @@ class ConnectivityCheckServer
|
|||||||
public byte[] getRemoteKey(String username, String media)
|
public byte[] getRemoteKey(String username, String media)
|
||||||
{
|
{
|
||||||
IceMediaStream stream = parentAgent.getStream(media);
|
IceMediaStream stream = parentAgent.getStream(media);
|
||||||
if(stream == null)
|
if (stream == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -399,7 +400,7 @@ class ConnectivityCheckServer
|
|||||||
//caller gave us the entire username.
|
//caller gave us the entire username.
|
||||||
if (username.equals(parentAgent.generateLocalUserName(media)))
|
if (username.equals(parentAgent.generateLocalUserName(media)))
|
||||||
{
|
{
|
||||||
if(stream.getRemotePassword() != null)
|
if (stream.getRemotePassword() != null)
|
||||||
return stream.getRemotePassword().getBytes();
|
return stream.getRemotePassword().getBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@ public class FoundationsRegistry
|
|||||||
|
|
||||||
StringBuffer foundationStringBuff = new StringBuffer(type);
|
StringBuffer foundationStringBuff = new StringBuffer(type);
|
||||||
foundationStringBuff.append(base);
|
foundationStringBuff.append(base);
|
||||||
if(server != null)
|
if (server != null)
|
||||||
foundationStringBuff.append(server);
|
foundationStringBuff.append(server);
|
||||||
|
|
||||||
foundationStringBuff.append(transport);
|
foundationStringBuff.append(transport);
|
||||||
@ -97,7 +97,7 @@ public class FoundationsRegistry
|
|||||||
|
|
||||||
//obtain a new foundation number if we don't have one for this kind
|
//obtain a new foundation number if we don't have one for this kind
|
||||||
//of candidates.
|
//of candidates.
|
||||||
if(foundationValue == null)
|
if (foundationValue == null)
|
||||||
{
|
{
|
||||||
foundationValue = Integer.toString(++lastAssignedFoundation);
|
foundationValue = Integer.toString(++lastAssignedFoundation);
|
||||||
foundations.put(foundationString, foundationValue);
|
foundations.put(foundationString, foundationValue);
|
||||||
|
|||||||
@ -103,7 +103,7 @@ public class GoogleRelayedCandidate
|
|||||||
turnCandidateHarvest.hostCandidate.getParentComponent()
|
turnCandidateHarvest.hostCandidate.getParentComponent()
|
||||||
.findLocalCandidate(mappedAddress));
|
.findLocalCandidate(mappedAddress));
|
||||||
|
|
||||||
if(transportAddress.getTransport() == Transport.TCP)
|
if (transportAddress.getTransport() == Transport.TCP)
|
||||||
{
|
{
|
||||||
super.setExtendedType(
|
super.setExtendedType(
|
||||||
CandidateExtendedType.GOOGLE_TCP_TURN_RELAYED_CANDIDATE);
|
CandidateExtendedType.GOOGLE_TCP_TURN_RELAYED_CANDIDATE);
|
||||||
@ -200,13 +200,13 @@ public class GoogleRelayedCandidate
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(getTransport() == Transport.UDP)
|
if (getTransport() == Transport.UDP)
|
||||||
{
|
{
|
||||||
socket
|
socket
|
||||||
= new IceUdpSocketWrapper(new MultiplexingDatagramSocket(
|
= new IceUdpSocketWrapper(new MultiplexingDatagramSocket(
|
||||||
getRelayedCandidateDatagramSocket()));
|
getRelayedCandidateDatagramSocket()));
|
||||||
}
|
}
|
||||||
else if(getTransport() == Transport.TCP)
|
else if (getTransport() == Transport.TCP)
|
||||||
{
|
{
|
||||||
final Socket s = getRelayedCandidateSocket();
|
final Socket s = getRelayedCandidateSocket();
|
||||||
socket = new IceTcpSocketWrapper(new MultiplexingSocket(s));
|
socket = new IceTcpSocketWrapper(new MultiplexingSocket(s));
|
||||||
|
|||||||
@ -374,7 +374,7 @@ public class IceMediaStream
|
|||||||
*/
|
*/
|
||||||
protected void createCheckList(List<CandidatePair> checkList)
|
protected void createCheckList(List<CandidatePair> checkList)
|
||||||
{
|
{
|
||||||
for(Component cmp : getComponents())
|
for (Component cmp : getComponents())
|
||||||
createCheckList(cmp, checkList);
|
createCheckList(cmp, checkList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,22 +393,22 @@ public class IceMediaStream
|
|||||||
List<RemoteCandidate> remoteCnds = component.getRemoteCandidates();
|
List<RemoteCandidate> remoteCnds = component.getRemoteCandidates();
|
||||||
LocalCandidate upnpBase = null;
|
LocalCandidate upnpBase = null;
|
||||||
|
|
||||||
for(LocalCandidate lc : localCnds)
|
for (LocalCandidate lc : localCnds)
|
||||||
{
|
{
|
||||||
// XXX do we assume a single UPNPCandidate here?
|
// XXX do we assume a single UPNPCandidate here?
|
||||||
if(lc instanceof UPNPCandidate)
|
if (lc instanceof UPNPCandidate)
|
||||||
upnpBase = lc.getBase();
|
upnpBase = lc.getBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(LocalCandidate localCnd : localCnds)
|
for (LocalCandidate localCnd : localCnds)
|
||||||
{
|
{
|
||||||
// Don't take into consideration UPnP base candidate
|
// Don't take into consideration UPnP base candidate
|
||||||
if(localCnd == upnpBase)
|
if (localCnd == upnpBase)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for(RemoteCandidate remoteCnd : remoteCnds)
|
for (RemoteCandidate remoteCnd : remoteCnds)
|
||||||
{
|
{
|
||||||
if(localCnd.canReach(remoteCnd)
|
if (localCnd.canReach(remoteCnd)
|
||||||
&& remoteCnd.getTransportAddress().getPort() != 0)
|
&& remoteCnd.getTransportAddress().getPort() != 0)
|
||||||
{
|
{
|
||||||
CandidatePair pair
|
CandidatePair pair
|
||||||
@ -454,12 +454,12 @@ public class IceMediaStream
|
|||||||
|
|
||||||
Iterator<CandidatePair> ckListIter = checkList.iterator();
|
Iterator<CandidatePair> ckListIter = checkList.iterator();
|
||||||
|
|
||||||
while(ckListIter.hasNext())
|
while (ckListIter.hasNext())
|
||||||
{
|
{
|
||||||
CandidatePair pair = ckListIter.next();
|
CandidatePair pair = ckListIter.next();
|
||||||
|
|
||||||
//drop all pairs above MAX_CHECK_LIST_SIZE.
|
//drop all pairs above MAX_CHECK_LIST_SIZE.
|
||||||
if(tmpCheckList.size() > maxCheckListSize)
|
if (tmpCheckList.size() > maxCheckListSize)
|
||||||
{
|
{
|
||||||
ckListIter.remove();
|
ckListIter.remove();
|
||||||
continue;
|
continue;
|
||||||
@ -467,14 +467,14 @@ public class IceMediaStream
|
|||||||
|
|
||||||
//replace local server reflexive candidates with their base.
|
//replace local server reflexive candidates with their base.
|
||||||
LocalCandidate localCnd = pair.getLocalCandidate();
|
LocalCandidate localCnd = pair.getLocalCandidate();
|
||||||
if( localCnd.getType()
|
if ( localCnd.getType()
|
||||||
== CandidateType.SERVER_REFLEXIVE_CANDIDATE)
|
== CandidateType.SERVER_REFLEXIVE_CANDIDATE)
|
||||||
{
|
{
|
||||||
pair.setLocalCandidate(localCnd.getBase());
|
pair.setLocalCandidate(localCnd.getBase());
|
||||||
|
|
||||||
//if the new pair corresponds to another one with a higher
|
//if the new pair corresponds to another one with a higher
|
||||||
//priority, then remove it.
|
//priority, then remove it.
|
||||||
if(tmpCheckList.contains(pair))
|
if (tmpCheckList.contains(pair))
|
||||||
{
|
{
|
||||||
ckListIter.remove();
|
ckListIter.remove();
|
||||||
continue;
|
continue;
|
||||||
@ -550,11 +550,11 @@ public class IceMediaStream
|
|||||||
*/
|
*/
|
||||||
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
|
public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress)
|
||||||
{
|
{
|
||||||
for( Component cmp : components.values())
|
for ( Component cmp : components.values())
|
||||||
{
|
{
|
||||||
RemoteCandidate cnd = cmp.findRemoteCandidate(remoteAddress);
|
RemoteCandidate cnd = cmp.findRemoteCandidate(remoteAddress);
|
||||||
|
|
||||||
if(cnd != null)
|
if (cnd != null)
|
||||||
return cnd;
|
return cnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -614,13 +614,13 @@ public class NetworkUtils
|
|||||||
return IN4_ADDR_ANY;
|
return IN4_ADDR_ANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(ifaces.hasMoreElements())
|
while (ifaces.hasMoreElements())
|
||||||
{
|
{
|
||||||
Enumeration<InetAddress> addrs
|
Enumeration<InetAddress> addrs
|
||||||
= ifaces.nextElement().getInetAddresses();
|
= ifaces.nextElement().getInetAddresses();
|
||||||
while (addrs.hasMoreElements())
|
while (addrs.hasMoreElements())
|
||||||
{
|
{
|
||||||
if(addrs.nextElement() instanceof Inet6Address)
|
if (addrs.nextElement() instanceof Inet6Address)
|
||||||
return IN6_ADDR_ANY;
|
return IN6_ADDR_ANY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -752,7 +752,7 @@ public class NetworkUtils
|
|||||||
|
|
||||||
//in case this was an IPv6 literal and we remove the closing bracket,
|
//in case this was an IPv6 literal and we remove the closing bracket,
|
||||||
//put it back in now.
|
//put it back in now.
|
||||||
if(ipv6Address.charAt(0) == '['
|
if (ipv6Address.charAt(0) == '['
|
||||||
&& ipv6Address.charAt(ipv6Address.length()-1) != ']')
|
&& ipv6Address.charAt(ipv6Address.length()-1) != ']')
|
||||||
{
|
{
|
||||||
ipv6Address += ']';
|
ipv6Address += ']';
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public class RemoteCandidate
|
|||||||
String foundation,
|
String foundation,
|
||||||
long priority,
|
long priority,
|
||||||
RemoteCandidate relatedCandidate,
|
RemoteCandidate relatedCandidate,
|
||||||
String ufrag)
|
String ufrag)
|
||||||
{
|
{
|
||||||
super(transportAddress, parentComponent, type, relatedCandidate);
|
super(transportAddress, parentComponent, type, relatedCandidate);
|
||||||
setFoundation(foundation);
|
setFoundation(foundation);
|
||||||
|
|||||||
@ -123,7 +123,7 @@ public class ServerReflexiveCandidate
|
|||||||
{
|
{
|
||||||
super.free();
|
super.free();
|
||||||
|
|
||||||
if(stunHarvest != null)
|
if (stunHarvest != null)
|
||||||
stunHarvest.close();
|
stunHarvest.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,7 @@ public class UPNPCandidate
|
|||||||
}
|
}
|
||||||
|
|
||||||
IceSocketWrapper socket = getCandidateIceSocketWrapper();
|
IceSocketWrapper socket = getCandidateIceSocketWrapper();
|
||||||
if(socket != null)
|
if (socket != null)
|
||||||
{
|
{
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public abstract class AbstractTcpListener
|
|||||||
|
|
||||||
Enumeration<InetAddress> ifaceAddresses = iface.getInetAddresses();
|
Enumeration<InetAddress> ifaceAddresses = iface.getInetAddresses();
|
||||||
|
|
||||||
while(ifaceAddresses.hasMoreElements())
|
while (ifaceAddresses.hasMoreElements())
|
||||||
{
|
{
|
||||||
InetAddress addr = ifaceAddresses.nextElement();
|
InetAddress addr = ifaceAddresses.nextElement();
|
||||||
|
|
||||||
@ -956,7 +956,7 @@ public abstract class AbstractTcpListener
|
|||||||
bytesRead, 2, bytesRead.length);
|
bytesRead, 2, bytesRead.length);
|
||||||
|
|
||||||
// if we had read enough data
|
// if we had read enough data
|
||||||
if(channel.length <= bytesRead.length - 2)
|
if (channel.length <= bytesRead.length - 2)
|
||||||
{
|
{
|
||||||
processFirstDatagram(
|
processFirstDatagram(
|
||||||
preBuffered, channel, key);
|
preBuffered, channel, key);
|
||||||
@ -991,7 +991,7 @@ public abstract class AbstractTcpListener
|
|||||||
channel.buffer.flip();
|
channel.buffer.flip();
|
||||||
channel.buffer.get(bytesRead);
|
channel.buffer.get(bytesRead);
|
||||||
|
|
||||||
if(channel.preBuffered != null)
|
if (channel.preBuffered != null)
|
||||||
{
|
{
|
||||||
// will store preBuffered and currently read data
|
// will store preBuffered and currently read data
|
||||||
byte[] newBytesRead = new byte[
|
byte[] newBytesRead = new byte[
|
||||||
|
|||||||
@ -96,7 +96,7 @@ class CandidateHarvesterSetElement
|
|||||||
{
|
{
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
else if(trickleCallback != null)
|
else if (trickleCallback != null)
|
||||||
{
|
{
|
||||||
trickleCallback.onIceCandidates(candidates);
|
trickleCallback.onIceCandidates(candidates);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public class GoogleTurnCandidateHarvest
|
|||||||
Attribute attribute
|
Attribute attribute
|
||||||
= response.getAttribute(Attribute.MAPPED_ADDRESS);
|
= response.getAttribute(Attribute.MAPPED_ADDRESS);
|
||||||
|
|
||||||
if(attribute != null)
|
if (attribute != null)
|
||||||
{
|
{
|
||||||
TransportAddress relayedAddress
|
TransportAddress relayedAddress
|
||||||
= ((MappedAddressAttribute) attribute).getAddress();
|
= ((MappedAddressAttribute) attribute).getAddress();
|
||||||
|
|||||||
@ -279,7 +279,7 @@ public class GoogleTurnSSLCandidateHarvester
|
|||||||
outputStream = null;
|
outputStream = null;
|
||||||
inputStream = null;
|
inputStream = null;
|
||||||
|
|
||||||
if(Arrays.equals(data, SSL_SERVER_HANDSHAKE))
|
if (Arrays.equals(data, SSL_SERVER_HANDSHAKE))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class HarvestStatistics
|
|||||||
protected void stopHarvestTiming(Collection<LocalCandidate> harvest)
|
protected void stopHarvestTiming(Collection<LocalCandidate> harvest)
|
||||||
{
|
{
|
||||||
//count total candidates
|
//count total candidates
|
||||||
if(harvest != null)
|
if (harvest != null)
|
||||||
stopHarvestTiming(harvest.size());
|
stopHarvestTiming(harvest.size());
|
||||||
else
|
else
|
||||||
stopHarvestTiming(0);
|
stopHarvestTiming(0);
|
||||||
@ -108,13 +108,13 @@ public class HarvestStatistics
|
|||||||
*/
|
*/
|
||||||
public long getHarvestDuration()
|
public long getHarvestDuration()
|
||||||
{
|
{
|
||||||
if(this.lastStartHarvestingTime != -1)
|
if (this.lastStartHarvestingTime != -1)
|
||||||
{
|
{
|
||||||
long currentHarvestingTime
|
long currentHarvestingTime
|
||||||
= System.currentTimeMillis() - lastStartHarvestingTime;
|
= System.currentTimeMillis() - lastStartHarvestingTime;
|
||||||
// Retest here, while the harvesting may be end while computing the
|
// Retest here, while the harvesting may be end while computing the
|
||||||
// harvesting time.
|
// harvesting time.
|
||||||
if(this.lastStartHarvestingTime != -1)
|
if (this.lastStartHarvestingTime != -1)
|
||||||
{
|
{
|
||||||
return this.lastHarvestingTime + currentHarvestingTime;
|
return this.lastHarvestingTime + currentHarvestingTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -304,7 +304,7 @@ public class HostCandidateHarvester
|
|||||||
|
|
||||||
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
|
||||||
if(transport != Transport.UDP && transport != Transport.TCP)
|
if (transport != Transport.UDP && transport != Transport.TCP)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Transport protocol not supported: " + transport);
|
throw new IllegalArgumentException("Transport protocol not supported: " + transport);
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ public class HostCandidateHarvester
|
|||||||
|
|
||||||
Enumeration<InetAddress> addresses = iface.getInetAddresses();
|
Enumeration<InetAddress> addresses = iface.getInetAddresses();
|
||||||
|
|
||||||
while(addresses.hasMoreElements())
|
while (addresses.hasMoreElements())
|
||||||
{
|
{
|
||||||
InetAddress addr = addresses.nextElement();
|
InetAddress addr = addresses.nextElement();
|
||||||
|
|
||||||
@ -342,19 +342,19 @@ public class HostCandidateHarvester
|
|||||||
}
|
}
|
||||||
foundAtLeastOneUsableAddress = true;
|
foundAtLeastOneUsableAddress = true;
|
||||||
|
|
||||||
if((addr instanceof Inet4Address) || !config.useIpv6())
|
if ((addr instanceof Inet4Address) || !config.useIpv6())
|
||||||
{
|
{
|
||||||
IceSocketWrapper sock = null;
|
IceSocketWrapper sock = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(transport == Transport.UDP)
|
if (transport == Transport.UDP)
|
||||||
{
|
{
|
||||||
sock = createDatagramSocket(addr, preferredPort, minPort, maxPort);
|
sock = createDatagramSocket(addr, preferredPort, minPort, maxPort);
|
||||||
boundAtLeastOneSocket = true;
|
boundAtLeastOneSocket = true;
|
||||||
}
|
}
|
||||||
else if(transport == Transport.TCP)
|
else if (transport == Transport.TCP)
|
||||||
{
|
{
|
||||||
if(addr instanceof Inet6Address)
|
if (addr instanceof Inet6Address)
|
||||||
continue;
|
continue;
|
||||||
sock = createServerSocket(
|
sock = createServerSocket(
|
||||||
addr,
|
addr,
|
||||||
@ -564,7 +564,7 @@ public class HostCandidateHarvester
|
|||||||
new DelegatingServerSocket(sock),
|
new DelegatingServerSocket(sock),
|
||||||
component);
|
component);
|
||||||
|
|
||||||
if(logger.isLoggable(Level.FINEST))
|
if (logger.isLoggable(Level.FINEST))
|
||||||
{
|
{
|
||||||
logger.log(
|
logger.log(
|
||||||
Level.FINEST,
|
Level.FINEST,
|
||||||
@ -647,7 +647,7 @@ public class HostCandidateHarvester
|
|||||||
= new IceUdpSocketWrapper(new
|
= new IceUdpSocketWrapper(new
|
||||||
MultiplexingDatagramSocket(port, laddr));
|
MultiplexingDatagramSocket(port, laddr));
|
||||||
|
|
||||||
if(logger.isLoggable(Level.FINEST))
|
if (logger.isLoggable(Level.FINEST))
|
||||||
{
|
{
|
||||||
logger.log(
|
logger.log(
|
||||||
Level.FINEST,
|
Level.FINEST,
|
||||||
|
|||||||
@ -196,7 +196,8 @@ public class MappingCandidateHarvesters
|
|||||||
|
|
||||||
for (MappingCandidateHarvester h : harvesters)
|
for (MappingCandidateHarvester h : harvesters)
|
||||||
{
|
{
|
||||||
if (face.getAddress().equals(h.getFace().getAddress()) && mask.getAddress().equals(h.getMask().getAddress()))
|
if (face.getAddress().equals(h.getFace().getAddress())
|
||||||
|
&& mask.getAddress().equals(h.getMask().getAddress()))
|
||||||
{
|
{
|
||||||
logger.info("Discarding a mapping harvester with duplicate "
|
logger.info("Discarding a mapping harvester with duplicate "
|
||||||
+ "addresses: " + harvester + ". Kept: " + h);
|
+ "addresses: " + harvester + ". Kept: " + h);
|
||||||
|
|||||||
@ -547,7 +547,7 @@ public class StunCandidateHarvest
|
|||||||
Attribute attribute
|
Attribute attribute
|
||||||
= response.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
|
= response.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
|
||||||
|
|
||||||
if(attribute instanceof XorMappedAddressAttribute)
|
if (attribute instanceof XorMappedAddressAttribute)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
((XorMappedAddressAttribute) attribute)
|
((XorMappedAddressAttribute) attribute)
|
||||||
@ -558,7 +558,7 @@ public class StunCandidateHarvest
|
|||||||
attribute
|
attribute
|
||||||
= response.getAttribute(Attribute.MAPPED_ADDRESS);
|
= response.getAttribute(Attribute.MAPPED_ADDRESS);
|
||||||
|
|
||||||
if(attribute instanceof MappedAddressAttribute)
|
if (attribute instanceof MappedAddressAttribute)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
((MappedAddressAttribute) attribute)
|
((MappedAddressAttribute) attribute)
|
||||||
|
|||||||
@ -111,9 +111,9 @@ public class StunCandidateHarvester
|
|||||||
this.shortTermCredentialUsername = shortTermCredentialUsername;
|
this.shortTermCredentialUsername = shortTermCredentialUsername;
|
||||||
|
|
||||||
//these should be configurable.
|
//these should be configurable.
|
||||||
if(System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER) == null)
|
if (System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER) == null)
|
||||||
System.setProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER, "400");
|
System.setProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER, "400");
|
||||||
if(System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS) == null)
|
if (System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS) == null)
|
||||||
System.setProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS, "3");
|
System.setProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS, "3");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ public class StunCandidateHarvester
|
|||||||
|
|
||||||
synchronized(startedHarvests)
|
synchronized(startedHarvests)
|
||||||
{
|
{
|
||||||
if(doNotify)
|
if (doNotify)
|
||||||
startedHarvests.notify();
|
startedHarvests.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ public class StunCandidateHarvester
|
|||||||
private String listCandidates(Collection<? extends Candidate<?>> candidates)
|
private String listCandidates(Collection<? extends Candidate<?>> candidates)
|
||||||
{
|
{
|
||||||
StringBuilder retval = new StringBuilder();
|
StringBuilder retval = new StringBuilder();
|
||||||
for(Candidate<?> candidate : candidates)
|
for (Candidate<?> candidate : candidates)
|
||||||
{
|
{
|
||||||
retval.append(candidate.toShortString());
|
retval.append(candidate.toShortString());
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ public class StunCandidateHarvester
|
|||||||
|
|
||||||
HostCandidate cand = getHostCandidate(hostCand);
|
HostCandidate cand = getHostCandidate(hostCand);
|
||||||
|
|
||||||
if(cand == null)
|
if (cand == null)
|
||||||
{
|
{
|
||||||
logger.info(
|
logger.info(
|
||||||
"server/candidate address type mismatch,"
|
"server/candidate address type mismatch,"
|
||||||
|
|||||||
@ -93,10 +93,10 @@ public class UPNPHarvester
|
|||||||
logger.fine("Begin UPnP harvesting");
|
logger.fine("Begin UPnP harvesting");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(device == null)
|
if (device == null)
|
||||||
{
|
{
|
||||||
// do it only once
|
// do it only once
|
||||||
if(finishThreads == 0)
|
if (finishThreads == 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -108,17 +108,17 @@ public class UPNPHarvester
|
|||||||
|
|
||||||
synchronized(rootSync)
|
synchronized(rootSync)
|
||||||
{
|
{
|
||||||
while(finishThreads != 2)
|
while (finishThreads != 2)
|
||||||
{
|
{
|
||||||
rootSync.wait();
|
rootSync.wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(wanIPThread.getDevice() != null)
|
if (wanIPThread.getDevice() != null)
|
||||||
{
|
{
|
||||||
device = wanIPThread.getDevice();
|
device = wanIPThread.getDevice();
|
||||||
}
|
}
|
||||||
else if(wanPPPThread.getDevice() != null)
|
else if (wanPPPThread.getDevice() != null)
|
||||||
{
|
{
|
||||||
device = wanPPPThread.getDevice();
|
device = wanPPPThread.getDevice();
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ public class UPNPHarvester
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(device == null)
|
if (device == null)
|
||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,12 +143,12 @@ public class UPNPHarvester
|
|||||||
int port = socket.getLocalPort();
|
int port = socket.getLocalPort();
|
||||||
int externalPort = socket.getLocalPort();
|
int externalPort = socket.getLocalPort();
|
||||||
|
|
||||||
while(retries < MAX_RETRIES)
|
while (retries < MAX_RETRIES)
|
||||||
{
|
{
|
||||||
if(!device.getSpecificPortMappingEntry(port, "UDP",
|
if (!device.getSpecificPortMappingEntry(port, "UDP",
|
||||||
portMapping))
|
portMapping))
|
||||||
{
|
{
|
||||||
if(device.addPortMapping(
|
if (device.addPortMapping(
|
||||||
externalPort,
|
externalPort,
|
||||||
port,
|
port,
|
||||||
localAddress.getHostAddress(),
|
localAddress.getHostAddress(),
|
||||||
@ -165,11 +165,11 @@ public class UPNPHarvester
|
|||||||
// if we don't add the base, we won't be able to add
|
// if we don't add the base, we won't be able to add
|
||||||
// peer reflexive candidate if someone contact us on the
|
// peer reflexive candidate if someone contact us on the
|
||||||
// UPNPCandidate
|
// UPNPCandidate
|
||||||
for(LocalCandidate cand : cands)
|
for (LocalCandidate cand : cands)
|
||||||
{
|
{
|
||||||
//try to add the candidate to the component and then
|
//try to add the candidate to the component and then
|
||||||
//only add it to the harvest not redundant
|
//only add it to the harvest not redundant
|
||||||
if(component.addLocalCandidate(cand))
|
if (component.addLocalCandidate(cand))
|
||||||
{
|
{
|
||||||
candidates.add(cand);
|
candidates.add(cand);
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ public class UPNPHarvester
|
|||||||
|
|
||||||
gd.discover();
|
gd.discover();
|
||||||
|
|
||||||
if(gd.getValidGateway() != null)
|
if (gd.getValidGateway() != null)
|
||||||
{
|
{
|
||||||
device = gd.getValidGateway();
|
device = gd.getValidGateway();
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ public class UPNPHarvester
|
|||||||
* a method, it is important that it be rethrown so that the
|
* a method, it is important that it be rethrown so that the
|
||||||
* thread actually dies.
|
* thread actually dies.
|
||||||
*/
|
*/
|
||||||
if(e instanceof ThreadDeath)
|
if (e instanceof ThreadDeath)
|
||||||
throw (ThreadDeath)e;
|
throw (ThreadDeath)e;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@ -151,15 +151,15 @@ public class IceSdpUtils
|
|||||||
Component firstComponent = null;
|
Component firstComponent = null;
|
||||||
|
|
||||||
//add candidates
|
//add candidates
|
||||||
for(Component component : iceMediaStream.getComponents())
|
for (Component component : iceMediaStream.getComponents())
|
||||||
{
|
{
|
||||||
//if this is the first component, remember it so that we can
|
//if this is the first component, remember it so that we can
|
||||||
//later use it for default candidates.
|
//later use it for default candidates.
|
||||||
if(firstComponent == null)
|
if (firstComponent == null)
|
||||||
firstComponent = component;
|
firstComponent = component;
|
||||||
|
|
||||||
Vector attributes = mediaDescription.getAttributes(true);
|
Vector attributes = mediaDescription.getAttributes(true);
|
||||||
for(Candidate<?> candidate : component.getLocalCandidates())
|
for (Candidate<?> candidate : component.getLocalCandidates())
|
||||||
{
|
{
|
||||||
attributes.add(new CandidateAttribute(candidate));
|
attributes.add(new CandidateAttribute(candidate));
|
||||||
}
|
}
|
||||||
@ -184,12 +184,12 @@ public class IceSdpUtils
|
|||||||
Component rtcpComponent
|
Component rtcpComponent
|
||||||
= iceMediaStream.getComponent(Component.RTCP);
|
= iceMediaStream.getComponent(Component.RTCP);
|
||||||
|
|
||||||
if( rtcpComponent != null )
|
if ( rtcpComponent != null )
|
||||||
{
|
{
|
||||||
TransportAddress defaultRtcpCandidate = rtcpComponent
|
TransportAddress defaultRtcpCandidate = rtcpComponent
|
||||||
.getDefaultCandidate().getTransportAddress();
|
.getDefaultCandidate().getTransportAddress();
|
||||||
|
|
||||||
if(defaultRtcpCandidate.getPort() != defaultAddress.getPort()+1)
|
if (defaultRtcpCandidate.getPort() != defaultAddress.getPort()+1)
|
||||||
{
|
{
|
||||||
mediaDescription.setAttribute(
|
mediaDescription.setAttribute(
|
||||||
RTCP, Integer.toString(defaultRtcpCandidate.getPort()));
|
RTCP, Integer.toString(defaultRtcpCandidate.getPort()));
|
||||||
@ -255,7 +255,7 @@ public class IceSdpUtils
|
|||||||
//origin
|
//origin
|
||||||
Origin o = sDes.getOrigin();
|
Origin o = sDes.getOrigin();
|
||||||
|
|
||||||
if( o == null || "user".equals(o.getUsername()))
|
if ( o == null || "user".equals(o.getUsername()))
|
||||||
{
|
{
|
||||||
//looks like there wasn't any origin set: jain-sdp creates a
|
//looks like there wasn't any origin set: jain-sdp creates a
|
||||||
//default origin that has "user" as the user name so we use this
|
//default origin that has "user" as the user name so we use this
|
||||||
@ -277,7 +277,7 @@ public class IceSdpUtils
|
|||||||
List<IceMediaStream> streams = agent.getStreams();
|
List<IceMediaStream> streams = agent.getStreams();
|
||||||
Vector<MediaDescription> mDescs
|
Vector<MediaDescription> mDescs
|
||||||
= new Vector<>(agent.getStreamCount());
|
= new Vector<>(agent.getStreamCount());
|
||||||
for(IceMediaStream stream : streams)
|
for (IceMediaStream stream : streams)
|
||||||
{
|
{
|
||||||
MediaDescription mLine = sdpFactory.createMediaDescription(
|
MediaDescription mLine = sdpFactory.createMediaDescription(
|
||||||
stream.getName(), 0, //default port comes later
|
stream.getName(), 0, //default port comes later
|
||||||
@ -320,7 +320,7 @@ public class IceSdpUtils
|
|||||||
{
|
{
|
||||||
List<Attribute> trickleUpdate = null;
|
List<Attribute> trickleUpdate = null;
|
||||||
|
|
||||||
if(localCandidates == null || localCandidates.size() == 0)
|
if (localCandidates == null || localCandidates.size() == 0)
|
||||||
{
|
{
|
||||||
trickleUpdate = new ArrayList<>(1);
|
trickleUpdate = new ArrayList<>(1);
|
||||||
trickleUpdate.add(
|
trickleUpdate.add(
|
||||||
@ -333,7 +333,7 @@ public class IceSdpUtils
|
|||||||
|
|
||||||
String streamName = null;
|
String streamName = null;
|
||||||
|
|
||||||
for(LocalCandidate candidate : localCandidates)
|
for (LocalCandidate candidate : localCandidates)
|
||||||
{
|
{
|
||||||
streamName = candidate.getParentComponent()
|
streamName = candidate.getParentComponent()
|
||||||
.getParentStream().getName();
|
.getParentStream().getName();
|
||||||
|
|||||||
@ -106,7 +106,7 @@ public class ChannelData
|
|||||||
*/
|
*/
|
||||||
public char getDataLength()
|
public char getDataLength()
|
||||||
{
|
{
|
||||||
if(data == null)
|
if (data == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (char)data.length;
|
return (char)data.length;
|
||||||
@ -159,7 +159,7 @@ public class ChannelData
|
|||||||
byte binMsg[] = new byte[HEADER_LENGTH + dataLength];
|
byte binMsg[] = new byte[HEADER_LENGTH + dataLength];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
if(!validateChannelNumber(channelNumber))
|
if (!validateChannelNumber(channelNumber))
|
||||||
{
|
{
|
||||||
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Channel number invalid");
|
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Channel number invalid");
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ public class ChannelData
|
|||||||
binMsg[offset++] = (byte)((data != null) ? data.length >> 8 : 0);
|
binMsg[offset++] = (byte)((data != null) ? data.length >> 8 : 0);
|
||||||
binMsg[offset++] = (byte)((data != null) ? data.length & 0xff : 0);
|
binMsg[offset++] = (byte)((data != null) ? data.length & 0xff : 0);
|
||||||
|
|
||||||
if(data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
System.arraycopy(data, 0, binMsg, offset, data.length);
|
System.arraycopy(data, 0, binMsg, offset, data.length);
|
||||||
}
|
}
|
||||||
@ -210,14 +210,14 @@ public class ChannelData
|
|||||||
ChannelData channelData = null;
|
ChannelData channelData = null;
|
||||||
byte data[] = null;
|
byte data[] = null;
|
||||||
|
|
||||||
if((binMessage.length - offset) < HEADER_LENGTH)
|
if ((binMessage.length - offset) < HEADER_LENGTH)
|
||||||
{
|
{
|
||||||
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Size too short");
|
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Size too short");
|
||||||
}
|
}
|
||||||
|
|
||||||
channelNumber = (char)((binMessage[offset++]<<8) | (binMessage[offset++]&0xFF));
|
channelNumber = (char)((binMessage[offset++]<<8) | (binMessage[offset++]&0xFF));
|
||||||
|
|
||||||
if(!validateChannelNumber(channelNumber))
|
if (!validateChannelNumber(channelNumber))
|
||||||
{
|
{
|
||||||
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Channel number invalid");
|
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Channel number invalid");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class Indication
|
|||||||
/* old TURN DATA indication type is an indication despite
|
/* old TURN DATA indication type is an indication despite
|
||||||
* 0x0115 & 0x0110 indicates STUN error response type
|
* 0x0115 & 0x0110 indicates STUN error response type
|
||||||
*/
|
*/
|
||||||
if(!isIndicationType(indicationType) &&
|
if (!isIndicationType(indicationType) &&
|
||||||
indicationType != OLD_DATA_INDICATION)
|
indicationType != OLD_DATA_INDICATION)
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
(int)(indicationType)
|
(int)(indicationType)
|
||||||
|
|||||||
@ -469,6 +469,7 @@ public abstract class Message
|
|||||||
/* Old TURN attributes */
|
/* Old TURN attributes */
|
||||||
protected static final byte DESTINATION_ADDRESS_PRESENTITY_INDEX = 29;
|
protected static final byte DESTINATION_ADDRESS_PRESENTITY_INDEX = 29;
|
||||||
|
|
||||||
|
// CHECKSTYLE:OFF
|
||||||
protected final static byte attributePresentities[][] = new byte[][]{
|
protected final static byte attributePresentities[][] = new byte[][]{
|
||||||
// Binding Shared Shared Shared Alloc Alloc Rfrsh Rfrsh ChnlBnd ChnlBnd Send Data
|
// Binding Shared Shared Shared Alloc Alloc Rfrsh Rfrsh ChnlBnd ChnlBnd Send Data
|
||||||
// Binding Binding Error Secret Secret Secret Req. Resp. Req. Resp. Req. Resp. Indic. Indic.
|
// Binding Binding Error Secret Secret Secret Req. Resp. Req. Resp. Req. Resp. Indic. Indic.
|
||||||
@ -509,6 +510,7 @@ public abstract class Message
|
|||||||
/*USE-CANDIDATE*/ { O, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A},
|
/*USE-CANDIDATE*/ { O, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A},
|
||||||
/*DESTINATION-ADDRESS*/{N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, O, N_A, N_A, N_A, M, N_A},
|
/*DESTINATION-ADDRESS*/{N_A, N_A, N_A, N_A, N_A, N_A, N_A, N_A, O, N_A, N_A, N_A, M, N_A},
|
||||||
};
|
};
|
||||||
|
// CHECKSTYLE:ON
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty STUN Message.
|
* Creates an empty STUN Message.
|
||||||
@ -687,7 +689,7 @@ public abstract class Message
|
|||||||
public void setTransactionID(byte[] tranID)
|
public void setTransactionID(byte[] tranID)
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(tranID == null
|
if (tranID == null
|
||||||
|| (tranID.length != TRANSACTION_ID_LENGTH &&
|
|| (tranID.length != TRANSACTION_ID_LENGTH &&
|
||||||
tranID.length != RFC3489_TRANSACTION_ID_LENGTH))
|
tranID.length != RFC3489_TRANSACTION_ID_LENGTH))
|
||||||
throw new StunException(StunException.ILLEGAL_ARGUMENT,
|
throw new StunException(StunException.ILLEGAL_ARGUMENT,
|
||||||
@ -721,7 +723,7 @@ public abstract class Message
|
|||||||
*/
|
*/
|
||||||
protected byte getAttributePresentity(char attributeType)
|
protected byte getAttributePresentity(char attributeType)
|
||||||
{
|
{
|
||||||
if(!rfc3489CompatibilityMode)
|
if (!rfc3489CompatibilityMode)
|
||||||
return O;
|
return O;
|
||||||
|
|
||||||
byte msgIndex = -1;
|
byte msgIndex = -1;
|
||||||
@ -872,22 +874,22 @@ public abstract class Message
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if(!(obj instanceof Message))
|
if (!(obj instanceof Message))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Message msg = (Message) obj;
|
Message msg = (Message) obj;
|
||||||
if( msg.getMessageType() != getMessageType())
|
if ( msg.getMessageType() != getMessageType())
|
||||||
return false;
|
return false;
|
||||||
if(msg.getDataLength() != getDataLength())
|
if (msg.getDataLength() != getDataLength())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//compare attributes
|
//compare attributes
|
||||||
for (Attribute localAtt : attributes.values())
|
for (Attribute localAtt : attributes.values())
|
||||||
{
|
{
|
||||||
if(!localAtt.equals(msg.getAttribute(localAtt.getAttributeType())))
|
if (!localAtt.equals(msg.getAttribute(localAtt.getAttributeType())))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -930,7 +932,7 @@ public abstract class Message
|
|||||||
|
|
||||||
byte tranID[] = getTransactionID();
|
byte tranID[] = getTransactionID();
|
||||||
|
|
||||||
if(tranID.length == 12)
|
if (tranID.length == 12)
|
||||||
{
|
{
|
||||||
System.arraycopy(MAGIC_COOKIE, 0, binMsg, offset, 4);
|
System.arraycopy(MAGIC_COOKIE, 0, binMsg, offset, 4);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
@ -1063,7 +1065,7 @@ public abstract class Message
|
|||||||
int originalOffset = offset;
|
int originalOffset = offset;
|
||||||
arrayLen = Math.min(binMessage.length, arrayLen);
|
arrayLen = Math.min(binMessage.length, arrayLen);
|
||||||
|
|
||||||
if(arrayLen - offset < Message.HEADER_LENGTH)
|
if (arrayLen - offset < Message.HEADER_LENGTH)
|
||||||
{
|
{
|
||||||
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
throw new StunException( StunException.ILLEGAL_ARGUMENT,
|
||||||
"The given binary array is not a valid StunMessage");
|
"The given binary array is not a valid StunMessage");
|
||||||
@ -1077,7 +1079,7 @@ public abstract class Message
|
|||||||
if (Message.isResponseType(messageType) &&
|
if (Message.isResponseType(messageType) &&
|
||||||
messageType != OLD_DATA_INDICATION)
|
messageType != OLD_DATA_INDICATION)
|
||||||
message = new Response();
|
message = new Response();
|
||||||
else if(Message.isRequestType(messageType))
|
else if (Message.isRequestType(messageType))
|
||||||
message = new Request();
|
message = new Request();
|
||||||
else /* indication */
|
else /* indication */
|
||||||
message = new Indication();
|
message = new Indication();
|
||||||
@ -1094,12 +1096,12 @@ public abstract class Message
|
|||||||
|
|
||||||
boolean rfc3489Compat = false;
|
boolean rfc3489Compat = false;
|
||||||
|
|
||||||
if(!Arrays.equals(MAGIC_COOKIE, cookie))
|
if (!Arrays.equals(MAGIC_COOKIE, cookie))
|
||||||
{
|
{
|
||||||
rfc3489Compat = true;
|
rfc3489Compat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(arrayLen - offset - TRANSACTION_ID_LENGTH < length)
|
if (arrayLen - offset - TRANSACTION_ID_LENGTH < length)
|
||||||
{
|
{
|
||||||
throw
|
throw
|
||||||
new StunException(
|
new StunException(
|
||||||
@ -1117,7 +1119,7 @@ public abstract class Message
|
|||||||
System.arraycopy(binMessage, offset, tranID, 0, TRANSACTION_ID_LENGTH);
|
System.arraycopy(binMessage, offset, tranID, 0, TRANSACTION_ID_LENGTH);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(rfc3489Compat)
|
if (rfc3489Compat)
|
||||||
{
|
{
|
||||||
byte[] rfc3489TranID = new byte[TRANSACTION_ID_LENGTH + 4];
|
byte[] rfc3489TranID = new byte[TRANSACTION_ID_LENGTH + 4];
|
||||||
System.arraycopy(cookie, 0, rfc3489TranID, 0, 4);
|
System.arraycopy(cookie, 0, rfc3489TranID, 0, 4);
|
||||||
@ -1139,7 +1141,7 @@ public abstract class Message
|
|||||||
|
|
||||||
offset += TRANSACTION_ID_LENGTH;
|
offset += TRANSACTION_ID_LENGTH;
|
||||||
|
|
||||||
while(offset - Message.HEADER_LENGTH < length)
|
while (offset - Message.HEADER_LENGTH < length)
|
||||||
{
|
{
|
||||||
Attribute att = AttributeDecoder.decode(
|
Attribute att = AttributeDecoder.decode(
|
||||||
binMessage, offset, (char)(length - offset));
|
binMessage, offset, (char)(length - offset));
|
||||||
@ -1152,7 +1154,7 @@ public abstract class Message
|
|||||||
|
|
||||||
//now also skip any potential padding that might have come with
|
//now also skip any potential padding that might have come with
|
||||||
//this attribute.
|
//this attribute.
|
||||||
if((att.getDataLength() % 4) > 0)
|
if ((att.getDataLength() % 4) > 0)
|
||||||
{
|
{
|
||||||
offset += (4 - (att.getDataLength() % 4));
|
offset += (4 - (att.getDataLength() % 4));
|
||||||
}
|
}
|
||||||
@ -1249,11 +1251,11 @@ public abstract class Message
|
|||||||
protected void validateAttributePresentity()
|
protected void validateAttributePresentity()
|
||||||
throws IllegalStateException
|
throws IllegalStateException
|
||||||
{
|
{
|
||||||
if(! rfc3489CompatibilityMode )
|
if (! rfc3489CompatibilityMode )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(char i = Attribute.MAPPED_ADDRESS; i < Attribute.REFLECTED_FROM;i++)
|
for (char i = Attribute.MAPPED_ADDRESS; i < Attribute.REFLECTED_FROM; i++)
|
||||||
if(getAttributePresentity(i) == M && getAttribute(i) == null)
|
if (getAttributePresentity(i) == M && getAttribute(i) == null)
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"A mandatory attribute (type=" + (int)i + ") is missing!");
|
"A mandatory attribute (type=" + (int)i + ") is missing!");
|
||||||
}
|
}
|
||||||
@ -1275,7 +1277,7 @@ public abstract class Message
|
|||||||
*/
|
*/
|
||||||
public static boolean isSuccessResponseType(char type)
|
public static boolean isSuccessResponseType(char type)
|
||||||
{
|
{
|
||||||
return ((type & MESSAGE_CLASS_MASK) == STUN_SUCCESS_RESP);
|
return ((type & MESSAGE_CLASS_MASK) == STUN_SUCCESS_RESP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1286,8 +1288,8 @@ public abstract class Message
|
|||||||
*/
|
*/
|
||||||
public static boolean isResponseType(char type)
|
public static boolean isResponseType(char type)
|
||||||
{
|
{
|
||||||
/* return (((type >> 8) & 1) != 0); */
|
/* return (((type >> 8) & 1) != 0); */
|
||||||
return (isSuccessResponseType(type) || isErrorResponseType(type));
|
return (isSuccessResponseType(type) || isErrorResponseType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1308,8 +1310,8 @@ public abstract class Message
|
|||||||
*/
|
*/
|
||||||
public static boolean isRequestType(char type)
|
public static boolean isRequestType(char type)
|
||||||
{
|
{
|
||||||
/* return !isResponseType(type); */
|
/* return !isResponseType(type); */
|
||||||
return ((type & MESSAGE_CLASS_MASK) == STUN_REQUEST);
|
return ((type & MESSAGE_CLASS_MASK) == STUN_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -54,7 +54,8 @@ public class MessageFactory
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
bindingRequest.setMessageType(Message.BINDING_REQUEST);
|
bindingRequest.setMessageType(Message.BINDING_REQUEST);
|
||||||
} catch (IllegalArgumentException ex)
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
// there should be no exc here since we're the creators.
|
// there should be no exc here since we're the creators.
|
||||||
logger.log(Level.FINE, "Failed to set message type.", ex);
|
logger.log(Level.FINE, "Failed to set message type.", ex);
|
||||||
@ -122,7 +123,8 @@ public class MessageFactory
|
|||||||
IceControllingAttribute iceControllingAttribute = AttributeFactory
|
IceControllingAttribute iceControllingAttribute = AttributeFactory
|
||||||
.createIceControllingAttribute(tieBreaker);
|
.createIceControllingAttribute(tieBreaker);
|
||||||
bindingRequest.putAttribute(iceControllingAttribute);
|
bindingRequest.putAttribute(iceControllingAttribute);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
IceControlledAttribute iceControlledAttribute = AttributeFactory
|
IceControlledAttribute iceControlledAttribute = AttributeFactory
|
||||||
.createIceControlledAttribute(tieBreaker);
|
.createIceControlledAttribute(tieBreaker);
|
||||||
@ -356,7 +358,8 @@ public class MessageFactory
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
allocateRequest.setMessageType(Message.ALLOCATE_REQUEST);
|
allocateRequest.setMessageType(Message.ALLOCATE_REQUEST);
|
||||||
} catch (IllegalArgumentException ex)
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
// there should be no exc here since we're the creators.
|
// there should be no exc here since we're the creators.
|
||||||
logger.log(Level.FINE, "Failed to set message type.", ex);
|
logger.log(Level.FINE, "Failed to set message type.", ex);
|
||||||
@ -428,8 +431,8 @@ public class MessageFactory
|
|||||||
int lifetime )
|
int lifetime )
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return createAllocationResponse(
|
return createAllocationResponse(
|
||||||
request, mappedAddress, relayedAddress, null ,lifetime);
|
request, mappedAddress, relayedAddress, null , lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,8 +476,8 @@ public class MessageFactory
|
|||||||
//xor relayed address
|
//xor relayed address
|
||||||
XorRelayedAddressAttribute xorRelayedAddressAttribute
|
XorRelayedAddressAttribute xorRelayedAddressAttribute
|
||||||
= AttributeFactory
|
= AttributeFactory
|
||||||
.createXorRelayedAddressAttribute(relayedAddress,
|
.createXorRelayedAddressAttribute(relayedAddress,
|
||||||
request.getTransactionID());
|
request.getTransactionID());
|
||||||
|
|
||||||
allocationSuccessResponse.putAttribute(xorRelayedAddressAttribute);
|
allocationSuccessResponse.putAttribute(xorRelayedAddressAttribute);
|
||||||
|
|
||||||
@ -484,12 +487,12 @@ public class MessageFactory
|
|||||||
|
|
||||||
allocationSuccessResponse.putAttribute(lifetimeAttribute);
|
allocationSuccessResponse.putAttribute(lifetimeAttribute);
|
||||||
|
|
||||||
if(token != null)
|
if (token != null)
|
||||||
{
|
{
|
||||||
//reservation token
|
//reservation token
|
||||||
ReservationTokenAttribute reservationTokenAttribute
|
ReservationTokenAttribute reservationTokenAttribute
|
||||||
= AttributeFactory
|
= AttributeFactory
|
||||||
.createReservationTokenAttribute(token);
|
.createReservationTokenAttribute(token);
|
||||||
|
|
||||||
allocationSuccessResponse.putAttribute(reservationTokenAttribute);
|
allocationSuccessResponse.putAttribute(reservationTokenAttribute);
|
||||||
}
|
}
|
||||||
@ -508,7 +511,7 @@ public class MessageFactory
|
|||||||
*/
|
*/
|
||||||
public static Response createAllocationErrorResponse(char errorCode)
|
public static Response createAllocationErrorResponse(char errorCode)
|
||||||
{
|
{
|
||||||
return createAllocationErrorResponse(errorCode,null);
|
return createAllocationErrorResponse(errorCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -524,7 +527,7 @@ public class MessageFactory
|
|||||||
* @return a allocation error response message containing an error code.
|
* @return a allocation error response message containing an error code.
|
||||||
*/
|
*/
|
||||||
public static Response createAllocationErrorResponse(char errorCode,
|
public static Response createAllocationErrorResponse(char errorCode,
|
||||||
String reasonPhrase)
|
String reasonPhrase)
|
||||||
{
|
{
|
||||||
Response allocationErrorResponse = new Response();
|
Response allocationErrorResponse = new Response();
|
||||||
|
|
||||||
@ -669,7 +672,8 @@ public class MessageFactory
|
|||||||
LifetimeAttribute lifetimeReq = AttributeFactory
|
LifetimeAttribute lifetimeReq = AttributeFactory
|
||||||
.createLifetimeAttribute(lifetime);
|
.createLifetimeAttribute(lifetime);
|
||||||
refreshRequest.putAttribute(lifetimeReq);
|
refreshRequest.putAttribute(lifetimeReq);
|
||||||
} catch (IllegalArgumentException ex)
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
logger.log(Level.FINE, "Failed to set message type.", ex);
|
logger.log(Level.FINE, "Failed to set message type.", ex);
|
||||||
}
|
}
|
||||||
@ -806,7 +810,7 @@ public class MessageFactory
|
|||||||
*/
|
*/
|
||||||
public static Response createChannelBindErrorResponse(char errorCode)
|
public static Response createChannelBindErrorResponse(char errorCode)
|
||||||
{
|
{
|
||||||
return createChannelBindErrorResponse(errorCode, null);
|
return createChannelBindErrorResponse(errorCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -826,7 +830,7 @@ public class MessageFactory
|
|||||||
|
|
||||||
ErrorCodeAttribute errorCodeAttribute
|
ErrorCodeAttribute errorCodeAttribute
|
||||||
= AttributeFactory
|
= AttributeFactory
|
||||||
.createErrorCodeAttribute(errorCode,reasonPhrase);
|
.createErrorCodeAttribute(errorCode, reasonPhrase);
|
||||||
|
|
||||||
channelBindErrorResponse.putAttribute(errorCodeAttribute);
|
channelBindErrorResponse.putAttribute(errorCodeAttribute);
|
||||||
|
|
||||||
@ -912,7 +916,7 @@ public class MessageFactory
|
|||||||
ErrorCodeAttribute errorCodeAttribute
|
ErrorCodeAttribute errorCodeAttribute
|
||||||
= AttributeFactory
|
= AttributeFactory
|
||||||
.createErrorCodeAttribute(
|
.createErrorCodeAttribute(
|
||||||
errorCode,reasonPhrase);
|
errorCode, reasonPhrase);
|
||||||
|
|
||||||
createPermissionErrorResponse.putAttribute(errorCodeAttribute);
|
createPermissionErrorResponse.putAttribute(errorCodeAttribute);
|
||||||
|
|
||||||
@ -949,7 +953,8 @@ public class MessageFactory
|
|||||||
.createDataAttribute(data);
|
.createDataAttribute(data);
|
||||||
sendIndication.putAttribute(dataAttribute);
|
sendIndication.putAttribute(dataAttribute);
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException ex)
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
logger.log(Level.FINE, "Failed to set message type.", ex);
|
logger.log(Level.FINE, "Failed to set message type.", ex);
|
||||||
}
|
}
|
||||||
@ -1180,7 +1185,7 @@ public class MessageFactory
|
|||||||
public static Response createConnectErrorResponse(char errorCode)
|
public static Response createConnectErrorResponse(char errorCode)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return createConnectErrorResponse(errorCode, null);
|
return createConnectErrorResponse(errorCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1270,7 +1275,7 @@ public class MessageFactory
|
|||||||
public static Response createConnectionBindErrorResponse(char errorCode)
|
public static Response createConnectionBindErrorResponse(char errorCode)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return createConnectionBindErrorResponse(errorCode,null);
|
return createConnectionBindErrorResponse(errorCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class Request extends Message
|
|||||||
public void setMessageType(char requestType)
|
public void setMessageType(char requestType)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(!isRequestType(requestType))
|
if (!isRequestType(requestType))
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
(int)(requestType)
|
(int)(requestType)
|
||||||
+ " - is not a valid request type.");
|
+ " - is not a valid request type.");
|
||||||
|
|||||||
@ -68,7 +68,7 @@ public class Response
|
|||||||
public void setMessageType(char responseType)
|
public void setMessageType(char responseType)
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(!isResponseType(responseType))
|
if (!isResponseType(responseType))
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
Integer.toString(responseType)
|
Integer.toString(responseType)
|
||||||
+ " is not a valid response type.");
|
+ " is not a valid response type.");
|
||||||
|
|||||||
@ -445,7 +445,8 @@ public class PseudoTCPBase
|
|||||||
|
|
||||||
long nInFlight = m_snd_nxt - m_snd_una;
|
long nInFlight = m_snd_nxt - m_snd_una;
|
||||||
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
|
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
|
||||||
//Logger.Log(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
|
//Logger.Log(LS_INFO)
|
||||||
|
// << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
|
||||||
m_cwnd = m_mss;
|
m_cwnd = m_mss;
|
||||||
|
|
||||||
// Back off retransmit timer. Note: the limit is lower when connecting.
|
// Back off retransmit timer. Note: the limit is lower when connecting.
|
||||||
@ -914,7 +915,7 @@ public class PseudoTCPBase
|
|||||||
public static String segToStr(Segment seg)
|
public static String segToStr(Segment seg)
|
||||||
{
|
{
|
||||||
String data="data: ";
|
String data="data: ";
|
||||||
for(byte b : seg.data)
|
for (byte b : seg.data)
|
||||||
{
|
{
|
||||||
data += b;
|
data += b;
|
||||||
}
|
}
|
||||||
@ -1064,7 +1065,7 @@ public class PseudoTCPBase
|
|||||||
bConnect = true;
|
bConnect = true;
|
||||||
|
|
||||||
// TCP options are in the remainder of the payload after CTL_CONNECT.
|
// TCP options are in the remainder of the payload after CTL_CONNECT.
|
||||||
if(!parseOptions(seg.data, 1, seg.len - 1))
|
if (!parseOptions(seg.data, 1, seg.len - 1))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1252,7 +1253,8 @@ public class PseudoTCPBase
|
|||||||
m_recover = m_snd_nxt;
|
m_recover = m_snd_nxt;
|
||||||
long nInFlight = m_snd_nxt - m_snd_una;
|
long nInFlight = m_snd_nxt - m_snd_una;
|
||||||
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
|
m_ssthresh = Math.max(nInFlight / 2, 2 * m_mss);
|
||||||
//Logger.Log(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
|
//Logger.Log(LS_INFO)
|
||||||
|
// << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
|
||||||
m_cwnd = m_ssthresh + 3 * m_mss;
|
m_cwnd = m_ssthresh + 3 * m_mss;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1757,11 +1759,11 @@ public class PseudoTCPBase
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_t_ack = now();
|
m_t_ack = now();
|
||||||
if (logger.isLoggable(Level.FINER))
|
if (logger.isLoggable(Level.FINER))
|
||||||
{
|
{
|
||||||
logger.log(
|
logger.log(
|
||||||
Level.FINER, "Delayed ack, m_t_ack: " + m_t_ack);
|
Level.FINER, "Delayed ack, m_t_ack: " + m_t_ack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2123,7 +2125,7 @@ public class PseudoTCPBase
|
|||||||
|
|
||||||
void setConversationID(long convID)
|
void setConversationID(long convID)
|
||||||
{
|
{
|
||||||
if(m_state != PseudoTcpState.TCP_LISTEN)
|
if (m_state != PseudoTcpState.TCP_LISTEN)
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
this.m_conv = convID;
|
this.m_conv = convID;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,13 +24,13 @@ import java.net.*;
|
|||||||
* @author Pawel Domas
|
* @author Pawel Domas
|
||||||
*/
|
*/
|
||||||
public class PseudoTcpJavaSocket extends Socket {
|
public class PseudoTcpJavaSocket extends Socket {
|
||||||
public PseudoTcpJavaSocket(long conv_id) throws SocketException {
|
public PseudoTcpJavaSocket(long conv_id) throws SocketException {
|
||||||
super(new PseudoTcpSocketImpl(conv_id));
|
super(new PseudoTcpSocketImpl(conv_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PseudoTcpJavaSocket(long conv_id, DatagramSocket socket)
|
public PseudoTcpJavaSocket(long conv_id, DatagramSocket socket)
|
||||||
throws SocketException {
|
throws SocketException {
|
||||||
super(new PseudoTcpSocketImpl(conv_id, socket));
|
super(new PseudoTcpSocketImpl(conv_id, socket));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,10 +34,10 @@ public class PseudoTcpSocket extends Socket
|
|||||||
|
|
||||||
PseudoTcpSocket(PseudoTcpSocketImpl socketImpl)
|
PseudoTcpSocket(PseudoTcpSocketImpl socketImpl)
|
||||||
throws SocketException
|
throws SocketException
|
||||||
{
|
{
|
||||||
super(socketImpl);
|
super(socketImpl);
|
||||||
this.socketImpl = socketImpl;
|
this.socketImpl = socketImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -60,62 +60,62 @@ public class PseudoTcpSocket extends Socket
|
|||||||
{
|
{
|
||||||
socketImpl.setConversationID(convID);
|
socketImpl.setConversationID(convID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets MTU (maximum transmission unit) value
|
* Sets MTU (maximum transmission unit) value
|
||||||
* @param mtu the MTU value
|
* @param mtu the MTU value
|
||||||
*/
|
*/
|
||||||
public void setMTU(int mtu)
|
public void setMTU(int mtu)
|
||||||
{
|
{
|
||||||
socketImpl.setMTU(mtu);
|
socketImpl.setMTU(mtu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets MTU (maximum transmission unit) value
|
* Gets MTU (maximum transmission unit) value
|
||||||
* @return MTU value
|
* @return MTU value
|
||||||
*/
|
*/
|
||||||
public int getMTU()
|
public int getMTU()
|
||||||
{
|
{
|
||||||
return socketImpl.getMTU();
|
return socketImpl.getMTU();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an {@link Option} on this socket.
|
* Sets an {@link Option} on this socket.
|
||||||
* @return PseudoTCP option value
|
* @return PseudoTCP option value
|
||||||
*
|
*
|
||||||
* @param option the option to set on this socket.
|
* @param option the option to set on this socket.
|
||||||
* @see Option
|
* @see Option
|
||||||
*/
|
*/
|
||||||
public long getOption(Option option)
|
public long getOption(Option option)
|
||||||
{
|
{
|
||||||
return socketImpl.getPTCPOption(option);
|
return socketImpl.getPTCPOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param option PseudoTCP option to set
|
* @param option PseudoTCP option to set
|
||||||
* @param optValue option's value
|
* @param optValue option's value
|
||||||
*
|
*
|
||||||
* @see Option
|
* @see Option
|
||||||
*/
|
*/
|
||||||
public void setOption(Option option, long optValue)
|
public void setOption(Option option, long optValue)
|
||||||
{
|
{
|
||||||
socketImpl.setPTCPOption(option, optValue);
|
socketImpl.setPTCPOption(option, optValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocking method waits for connection.
|
* Blocking method waits for connection.
|
||||||
*
|
*
|
||||||
* @param timeout for this operation in ms
|
* @param timeout for this operation in ms
|
||||||
* @throws IOException If socket gets closed or timeout expires
|
* @throws IOException If socket gets closed or timeout expires
|
||||||
*/
|
*/
|
||||||
public void accept(int timeout)
|
public void accept(int timeout)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
socketImpl.accept(timeout);
|
socketImpl.accept(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets debug name that will be displayed in log messages for this socket
|
* Sets debug name that will be displayed in log messages for this socket
|
||||||
* @param debugName the name of this socket for debug messages
|
* @param debugName the name of this socket for debug messages
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -250,9 +250,9 @@ class PseudoTcpSocketImpl
|
|||||||
public void bind(InetAddress host, int port)
|
public void bind(InetAddress host, int port)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if(socket != null)
|
if (socket != null)
|
||||||
socket.close();
|
socket.close();
|
||||||
InetSocketAddress newAddr = new InetSocketAddress(host.getHostAddress(),port);
|
InetSocketAddress newAddr = new InetSocketAddress(host.getHostAddress(), port);
|
||||||
this.socket = new DatagramSocket(newAddr);
|
this.socket = new DatagramSocket(newAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,27 +282,27 @@ class PseudoTcpSocketImpl
|
|||||||
throws SocketException
|
throws SocketException
|
||||||
{
|
{
|
||||||
//TODO: map options to PTCP options/method calls
|
//TODO: map options to PTCP options/method calls
|
||||||
if(optID == SocketOptions.TCP_NODELAY)
|
if (optID == SocketOptions.TCP_NODELAY)
|
||||||
{
|
{
|
||||||
Object ret = options.get(Option.OPT_NODELAY.ordinal());
|
Object ret = options.get(Option.OPT_NODELAY.ordinal());
|
||||||
return ret != null;
|
return ret != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object option = options.get(optID);
|
Object option = options.get(optID);
|
||||||
if(option == null)
|
if (option == null)
|
||||||
{
|
{
|
||||||
logger.warning("Asked for unknown optID" + optID);
|
logger.warning("Asked for unknown optID" + optID);
|
||||||
}
|
}
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPTCPOption(Option opt)
|
public long getPTCPOption(Option opt)
|
||||||
{
|
{
|
||||||
if(Option.OPT_READ_TIMEOUT == opt)
|
if (Option.OPT_READ_TIMEOUT == opt)
|
||||||
{
|
{
|
||||||
return this.readTimeout;
|
return this.readTimeout;
|
||||||
}
|
}
|
||||||
else if(Option.OPT_WRITE_TIMEOUT == opt)
|
else if (Option.OPT_WRITE_TIMEOUT == opt)
|
||||||
{
|
{
|
||||||
return this.writeTimeout;
|
return this.writeTimeout;
|
||||||
}
|
}
|
||||||
@ -314,11 +314,11 @@ class PseudoTcpSocketImpl
|
|||||||
|
|
||||||
public void setPTCPOption(Option opt, long optValue)
|
public void setPTCPOption(Option opt, long optValue)
|
||||||
{
|
{
|
||||||
if(Option.OPT_WRITE_TIMEOUT == opt)
|
if (Option.OPT_WRITE_TIMEOUT == opt)
|
||||||
{
|
{
|
||||||
this.writeTimeout = optValue >= 0 ? optValue : 0;
|
this.writeTimeout = optValue >= 0 ? optValue : 0;
|
||||||
}
|
}
|
||||||
else if(Option.OPT_READ_TIMEOUT == opt)
|
else if (Option.OPT_READ_TIMEOUT == opt)
|
||||||
{
|
{
|
||||||
this.readTimeout = optValue >= 0 ? optValue : 0;
|
this.readTimeout = optValue >= 0 ? optValue : 0;
|
||||||
}
|
}
|
||||||
@ -453,7 +453,7 @@ class PseudoTcpSocketImpl
|
|||||||
*/
|
*/
|
||||||
private void updateClock()
|
private void updateClock()
|
||||||
{
|
{
|
||||||
scheduleClockTask(0);
|
scheduleClockTask(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -503,7 +503,7 @@ class PseudoTcpSocketImpl
|
|||||||
*/
|
*/
|
||||||
public void onTcpReadable(PseudoTCPBase tcp)
|
public void onTcpReadable(PseudoTCPBase tcp)
|
||||||
{
|
{
|
||||||
if(logger.isLoggable(Level.FINER))
|
if (logger.isLoggable(Level.FINER))
|
||||||
{
|
{
|
||||||
logger.log(
|
logger.log(
|
||||||
Level.FINER,
|
Level.FINER,
|
||||||
@ -560,7 +560,7 @@ class PseudoTcpSocketImpl
|
|||||||
runClock = false;
|
runClock = false;
|
||||||
this.exception = e;
|
this.exception = e;
|
||||||
releaseAllLocks();
|
releaseAllLocks();
|
||||||
cancelClockTask(true);
|
cancelClockTask(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,70 +709,70 @@ class PseudoTcpSocketImpl
|
|||||||
*/
|
*/
|
||||||
private void runClock()
|
private void runClock()
|
||||||
{
|
{
|
||||||
if(!runClock)
|
if (!runClock)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long sleep;
|
long sleep;
|
||||||
|
|
||||||
synchronized (pseudoTcp)
|
synchronized (pseudoTcp)
|
||||||
{
|
{
|
||||||
pseudoTcp.notifyClock(PseudoTCPBase.now());
|
pseudoTcp.notifyClock(PseudoTCPBase.now());
|
||||||
sleep = pseudoTcp.getNextClock(PseudoTCPBase.now());
|
sleep = pseudoTcp.getNextClock(PseudoTCPBase.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
//there might be negative interval even if there's no error
|
//there might be negative interval even if there's no error
|
||||||
if (sleep == -1)
|
if (sleep == -1)
|
||||||
{
|
{
|
||||||
releaseAllLocks();
|
releaseAllLocks();
|
||||||
if (exception != null)
|
if (exception != null)
|
||||||
{
|
{
|
||||||
logger.log(Level.SEVERE,
|
logger.log(Level.SEVERE,
|
||||||
"STATE: " + pseudoTcp.getState()
|
"STATE: " + pseudoTcp.getState()
|
||||||
+ " ERROR: " + exception.getMessage());
|
+ " ERROR: " + exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//logger.log(Level.FINEST, "Clock sleep for " + sleep);
|
//logger.log(Level.FINEST, "Clock sleep for " + sleep);
|
||||||
scheduleClockTask(sleep);
|
scheduleClockTask(sleep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable clockTaskRunner = new Runnable()
|
private Runnable clockTaskRunner = new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
runClock();
|
runClock();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void scheduleClockTask(long sleep)
|
private void scheduleClockTask(long sleep)
|
||||||
{
|
{
|
||||||
synchronized (clockTaskRunner)
|
synchronized (clockTaskRunner)
|
||||||
{
|
{
|
||||||
// Cancel any existing tasks, to make sure we don't run duplicates.
|
// Cancel any existing tasks, to make sure we don't run duplicates.
|
||||||
cancelClockTask(false);
|
cancelClockTask(false);
|
||||||
if(runClock)
|
if (runClock)
|
||||||
{
|
{
|
||||||
currentlyScheduledClockTask
|
currentlyScheduledClockTask
|
||||||
= clockExecutor.schedule(
|
= clockExecutor.schedule(
|
||||||
clockTaskRunner, sleep, TimeUnit.MILLISECONDS);
|
clockTaskRunner, sleep, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelClockTask(boolean interruptIfRunning)
|
private void cancelClockTask(boolean interruptIfRunning)
|
||||||
{
|
{
|
||||||
// Copy the reference, in case it changes.
|
// Copy the reference, in case it changes.
|
||||||
ScheduledFuture<?> taskToCancel = this.currentlyScheduledClockTask;
|
ScheduledFuture<?> taskToCancel = this.currentlyScheduledClockTask;
|
||||||
if(taskToCancel != null)
|
if (taskToCancel != null)
|
||||||
{
|
{
|
||||||
taskToCancel.cancel(interruptIfRunning);
|
taskToCancel.cancel(interruptIfRunning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an output stream for this socket.
|
* Returns an output stream for this socket.
|
||||||
* @return an output stream for writing to this socket.
|
* @return an output stream for writing to this socket.
|
||||||
* @throws IOException if an I/O error occurs when creating the output stream.
|
* @throws IOException if an I/O error occurs when creating the output stream.
|
||||||
@ -926,12 +926,12 @@ class PseudoTcpSocketImpl
|
|||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
logger.log(Level.FINER, "Read wait for data available");
|
logger.log(Level.FINER, "Read wait for data available");
|
||||||
if(readTimeout > 0)
|
if (readTimeout > 0)
|
||||||
{
|
{
|
||||||
//Check for timeout
|
//Check for timeout
|
||||||
long elapsed = System.currentTimeMillis() - start;
|
long elapsed = System.currentTimeMillis() - start;
|
||||||
long left = readTimeout - elapsed;
|
long left = readTimeout - elapsed;
|
||||||
if(left <= 0)
|
if (left <= 0)
|
||||||
{
|
{
|
||||||
IOException exc =
|
IOException exc =
|
||||||
new IOException("Read operation timeout");
|
new IOException("Read operation timeout");
|
||||||
@ -940,7 +940,7 @@ class PseudoTcpSocketImpl
|
|||||||
}
|
}
|
||||||
synchronized (read_notify)
|
synchronized (read_notify)
|
||||||
{
|
{
|
||||||
if(pseudoTcp.getAvailable() == 0)
|
if (pseudoTcp.getAvailable() == 0)
|
||||||
{
|
{
|
||||||
read_notify.wait(left);
|
read_notify.wait(left);
|
||||||
}
|
}
|
||||||
@ -950,7 +950,7 @@ class PseudoTcpSocketImpl
|
|||||||
{
|
{
|
||||||
synchronized (read_notify)
|
synchronized (read_notify)
|
||||||
{
|
{
|
||||||
if(pseudoTcp.getAvailable() == 0)
|
if (pseudoTcp.getAvailable() == 0)
|
||||||
{
|
{
|
||||||
read_notify.wait();
|
read_notify.wait();
|
||||||
}
|
}
|
||||||
@ -1071,11 +1071,11 @@ class PseudoTcpSocketImpl
|
|||||||
logger.log(Level.FINER, "Write wait for notify");
|
logger.log(Level.FINER, "Write wait for notify");
|
||||||
synchronized (write_notify)
|
synchronized (write_notify)
|
||||||
{
|
{
|
||||||
if(writeTimeout > 0)
|
if (writeTimeout > 0)
|
||||||
{
|
{
|
||||||
long elapsed = System.currentTimeMillis() - start;
|
long elapsed = System.currentTimeMillis() - start;
|
||||||
long left = writeTimeout - elapsed;
|
long left = writeTimeout - elapsed;
|
||||||
if(left <= 0)
|
if (left <= 0)
|
||||||
{
|
{
|
||||||
IOException exc =
|
IOException exc =
|
||||||
new IOException("Write operation timeout");
|
new IOException("Write operation timeout");
|
||||||
@ -1129,12 +1129,12 @@ class PseudoTcpSocketImpl
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(writeTimeout > 0)
|
if (writeTimeout > 0)
|
||||||
{
|
{
|
||||||
//Check write timeout
|
//Check write timeout
|
||||||
long elapsed = System.currentTimeMillis() - start;
|
long elapsed = System.currentTimeMillis() - start;
|
||||||
long left = writeTimeout - elapsed;
|
long left = writeTimeout - elapsed;
|
||||||
if(left <= 0)
|
if (left <= 0)
|
||||||
{
|
{
|
||||||
IOException e =
|
IOException e =
|
||||||
new IOException("Flush operation timeout");
|
new IOException("Flush operation timeout");
|
||||||
|
|||||||
@ -26,23 +26,23 @@ public enum PseudoTcpState
|
|||||||
/**
|
/**
|
||||||
* Initial state, can accept connection
|
* Initial state, can accept connection
|
||||||
*/
|
*/
|
||||||
TCP_LISTEN,// = 0,
|
TCP_LISTEN, // = 0,
|
||||||
/**
|
/**
|
||||||
* SYN sent to remote peer, wits for SYN
|
* SYN sent to remote peer, wits for SYN
|
||||||
*/
|
*/
|
||||||
TCP_SYN_SENT,// = 1,
|
TCP_SYN_SENT, // = 1,
|
||||||
/**
|
/**
|
||||||
* SYN received from remote peer, sends back SYN
|
* SYN received from remote peer, sends back SYN
|
||||||
*/
|
*/
|
||||||
TCP_SYN_RECEIVED,// = 2;
|
TCP_SYN_RECEIVED, // = 2;
|
||||||
/**
|
/**
|
||||||
* SYN sent and received - connection established
|
* SYN sent and received - connection established
|
||||||
*/
|
*/
|
||||||
TCP_ESTABLISHED,// = 3;
|
TCP_ESTABLISHED, // = 3;
|
||||||
/**
|
/**
|
||||||
* Closed state. In current implementation reached on error
|
* Closed state. In current implementation reached on error
|
||||||
* or explicite by close method with force option
|
* or explicite by close method with force option
|
||||||
* TODO: closing procedure
|
* TODO: closing procedure
|
||||||
*/
|
*/
|
||||||
TCP_CLOSED// = 4;
|
TCP_CLOSED // = 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -225,7 +225,7 @@ public class DelegatingDatagramSocket
|
|||||||
|
|
||||||
// Delegates the DatagramSocket functionality to the DatagramSocket
|
// Delegates the DatagramSocket functionality to the DatagramSocket
|
||||||
// given in parameter.
|
// given in parameter.
|
||||||
if(delegate != null)
|
if (delegate != null)
|
||||||
{
|
{
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ public class DelegatingDatagramSocket
|
|||||||
{
|
{
|
||||||
// Creates a custom DatagramSocket to replace classical "java"
|
// Creates a custom DatagramSocket to replace classical "java"
|
||||||
// DatagramSocket and set it as a delegate Socket
|
// DatagramSocket and set it as a delegate Socket
|
||||||
if(delegateFactory != null)
|
if (delegateFactory != null)
|
||||||
{
|
{
|
||||||
this.delegate = delegateFactory.createUnboundDatagramSocket();
|
this.delegate = delegateFactory.createUnboundDatagramSocket();
|
||||||
}
|
}
|
||||||
@ -741,7 +741,7 @@ public class DelegatingDatagramSocket
|
|||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
InetAddress tmpAddr = p.getAddress();
|
InetAddress tmpAddr = p.getAddress();
|
||||||
if(((ex instanceof NoRouteToHostException)
|
if (((ex instanceof NoRouteToHostException)
|
||||||
|| (ex.getMessage() != null
|
|| (ex.getMessage() != null
|
||||||
&& ex.getMessage().equals("No route to host")))
|
&& ex.getMessage().equals("No route to host")))
|
||||||
&& (tmpAddr instanceof Inet6Address)
|
&& (tmpAddr instanceof Inet6Address)
|
||||||
@ -755,9 +755,10 @@ public class DelegatingDatagramSocket
|
|||||||
p.setAddress(newAddr);
|
p.setAddress(newAddr);
|
||||||
|
|
||||||
super.send(p);
|
super.send(p);
|
||||||
|
}
|
||||||
} else if (ex instanceof IOException) {
|
else if (ex instanceof IOException)
|
||||||
throw((IOException)ex);
|
{
|
||||||
|
throw((IOException)ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,7 +941,7 @@ public class DelegatingDatagramSocket
|
|||||||
throws SocketException
|
throws SocketException
|
||||||
{
|
{
|
||||||
// Only change the buffer size on the real underlying DatagramSocket.
|
// Only change the buffer size on the real underlying DatagramSocket.
|
||||||
if(delegate == null && defaultReceiveBufferSize > 0)
|
if (delegate == null && defaultReceiveBufferSize > 0)
|
||||||
{
|
{
|
||||||
super.setReceiveBufferSize(defaultReceiveBufferSize);
|
super.setReceiveBufferSize(defaultReceiveBufferSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -796,7 +796,7 @@ public class DelegatingSocket
|
|||||||
*/
|
*/
|
||||||
public void setOriginalInputStream(InputStream inputStream)
|
public void setOriginalInputStream(InputStream inputStream)
|
||||||
{
|
{
|
||||||
if(this.inputStream == null && inputStream != null)
|
if (this.inputStream == null && inputStream != null)
|
||||||
this.inputStream = inputStream;
|
this.inputStream = inputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -250,12 +250,12 @@ public class GoogleRelayedCandidateSocket
|
|||||||
public OutputStream getOutputStream()
|
public OutputStream getOutputStream()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if(outputStream == null)
|
if (outputStream == null)
|
||||||
{
|
{
|
||||||
CandidatePair pair =
|
CandidatePair pair =
|
||||||
relayedCandidate.getParentComponent().getSelectedPair();
|
relayedCandidate.getParentComponent().getSelectedPair();
|
||||||
|
|
||||||
if(pair.getLocalCandidate() == relayedCandidate)
|
if (pair.getLocalCandidate() == relayedCandidate)
|
||||||
{
|
{
|
||||||
TransportAddress target = pair.getRemoteCandidate().
|
TransportAddress target = pair.getRemoteCandidate().
|
||||||
getTransportAddress();
|
getTransportAddress();
|
||||||
|
|||||||
@ -107,7 +107,7 @@ public class IceTcpServerSocketWrapper
|
|||||||
{
|
{
|
||||||
isRun = false;
|
isRun = false;
|
||||||
serverSocket.close();
|
serverSocket.close();
|
||||||
for(Socket s : sockets)
|
for (Socket s : sockets)
|
||||||
{
|
{
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ public class IceTcpServerSocketWrapper
|
|||||||
@Override
|
@Override
|
||||||
public Socket getTCPSocket()
|
public Socket getTCPSocket()
|
||||||
{
|
{
|
||||||
if(sockets.size() > 0)
|
if (sockets.size() > 0)
|
||||||
{
|
{
|
||||||
return sockets.get(0);
|
return sockets.get(0);
|
||||||
}
|
}
|
||||||
@ -182,13 +182,13 @@ public class IceTcpServerSocketWrapper
|
|||||||
{
|
{
|
||||||
isRun = true;
|
isRun = true;
|
||||||
|
|
||||||
while(isRun)
|
while (isRun)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Socket tcpSocket = serverSocket.accept();
|
Socket tcpSocket = serverSocket.accept();
|
||||||
|
|
||||||
if(tcpSocket != null)
|
if (tcpSocket != null)
|
||||||
{
|
{
|
||||||
MultiplexingSocket multiplexingSocket =
|
MultiplexingSocket multiplexingSocket =
|
||||||
new MultiplexingSocket(tcpSocket);
|
new MultiplexingSocket(tcpSocket);
|
||||||
|
|||||||
@ -276,7 +276,7 @@ public class MultiplexedSocket
|
|||||||
public void reset()
|
public void reset()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if(!markSupported())
|
if (!markSupported())
|
||||||
{
|
{
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"InputStreamImpl does not support reset()");
|
"InputStreamImpl does not support reset()");
|
||||||
|
|||||||
@ -322,7 +322,7 @@ public class MultiplexingSocket
|
|||||||
@Override
|
@Override
|
||||||
public int getSoTimeout()
|
public int getSoTimeout()
|
||||||
{
|
{
|
||||||
return soTimeout;
|
return soTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -427,10 +427,10 @@ public class MultiplexingSocket
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setSoTimeout(int timeout)
|
public void setSoTimeout(int timeout)
|
||||||
throws SocketException
|
throws SocketException
|
||||||
{
|
{
|
||||||
super.setSoTimeout(timeout);
|
super.setSoTimeout(timeout);
|
||||||
|
|
||||||
soTimeout = timeout;
|
soTimeout = timeout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -159,7 +159,7 @@ public class MuxServerSocketChannelFactory
|
|||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public static ServerSocketChannel openAndBindMuxServerSocketChannel(
|
public static ServerSocketChannel openAndBindMuxServerSocketChannel(
|
||||||
Map<String,Object> properties,
|
Map<String, Object> properties,
|
||||||
SocketAddress endpoint,
|
SocketAddress endpoint,
|
||||||
int backlog,
|
int backlog,
|
||||||
DatagramPacketFilter filter)
|
DatagramPacketFilter filter)
|
||||||
@ -225,7 +225,7 @@ public class MuxServerSocketChannelFactory
|
|||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public static ServerSocketChannel openAndBindServerSocketChannel(
|
public static ServerSocketChannel openAndBindServerSocketChannel(
|
||||||
Map<String,Object> properties,
|
Map<String, Object> properties,
|
||||||
SocketAddress endpoint,
|
SocketAddress endpoint,
|
||||||
int backlog)
|
int backlog)
|
||||||
throws IOException
|
throws IOException
|
||||||
@ -236,7 +236,7 @@ public class MuxServerSocketChannelFactory
|
|||||||
|
|
||||||
if (properties != null && !properties.isEmpty())
|
if (properties != null && !properties.isEmpty())
|
||||||
{
|
{
|
||||||
for (Map.Entry<String,Object> property
|
for (Map.Entry<String, Object> property
|
||||||
: properties.entrySet())
|
: properties.entrySet())
|
||||||
{
|
{
|
||||||
String name = property.getKey();
|
String name = property.getKey();
|
||||||
|
|||||||
@ -296,7 +296,7 @@ public class RelayedCandidateDatagramSocket
|
|||||||
* DatagramPacket.
|
* DatagramPacket.
|
||||||
*/
|
*/
|
||||||
return length == pLength - padding - CHANNELDATA_LENGTH_LENGTH
|
return length == pLength - padding - CHANNELDATA_LENGTH_LENGTH
|
||||||
|| length == pLength - CHANNELDATA_LENGTH_LENGTH;
|
|| length == pLength - CHANNELDATA_LENGTH_LENGTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1162,7 +1162,7 @@ public class RelayedCandidateDatagramSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a channel which relays data sent through this
|
* Represents a channel which relays data sent through this
|
||||||
* <tt>RelayedCandidateDatagramSocket</tt> to a specific
|
* <tt>RelayedCandidateDatagramSocket</tt> to a specific
|
||||||
* <tt>TransportAddress</tt> via the TURN server associated with this
|
* <tt>TransportAddress</tt> via the TURN server associated with this
|
||||||
|
|||||||
@ -184,11 +184,11 @@ public class StunDatagramPacketFilter
|
|||||||
|
|
||||||
// All STUN messages MUST start with a 20-byte header followed by zero
|
// All STUN messages MUST start with a 20-byte header followed by zero
|
||||||
// or more Attributes.
|
// or more Attributes.
|
||||||
if(length >= 20)
|
if (length >= 20)
|
||||||
{
|
{
|
||||||
// If the MAGIC COOKIE is present this is a STUN packet (RFC5389
|
// If the MAGIC COOKIE is present this is a STUN packet (RFC5389
|
||||||
// compliant).
|
// compliant).
|
||||||
if(data[offset + 4] == Message.MAGIC_COOKIE[0]
|
if (data[offset + 4] == Message.MAGIC_COOKIE[0]
|
||||||
&& data[offset + 5] == Message.MAGIC_COOKIE[1]
|
&& data[offset + 5] == Message.MAGIC_COOKIE[1]
|
||||||
&& data[offset + 6] == Message.MAGIC_COOKIE[2]
|
&& data[offset + 6] == Message.MAGIC_COOKIE[2]
|
||||||
&& data[offset + 7] == Message.MAGIC_COOKIE[3])
|
&& data[offset + 7] == Message.MAGIC_COOKIE[3])
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class MuxServerSocketChannel
|
|||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public static MuxServerSocketChannel openAndBind(
|
public static MuxServerSocketChannel openAndBind(
|
||||||
Map<String,Object> properties,
|
Map<String, Object> properties,
|
||||||
SocketAddress endpoint,
|
SocketAddress endpoint,
|
||||||
int backlog,
|
int backlog,
|
||||||
DatagramPacketFilter filter)
|
DatagramPacketFilter filter)
|
||||||
|
|||||||
@ -270,7 +270,7 @@ class MuxingServerSocketChannel
|
|||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs
|
||||||
*/
|
*/
|
||||||
public static MuxServerSocketChannel openAndBind(
|
public static MuxServerSocketChannel openAndBind(
|
||||||
Map<String,Object> properties,
|
Map<String, Object> properties,
|
||||||
SocketAddress endpoint,
|
SocketAddress endpoint,
|
||||||
int backlog,
|
int backlog,
|
||||||
DatagramPacketFilter filter)
|
DatagramPacketFilter filter)
|
||||||
|
|||||||
@ -210,7 +210,8 @@ class Connector
|
|||||||
if (!running)
|
if (!running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (logger.isLoggable(Level.FINEST)){
|
if (logger.isLoggable(Level.FINEST))
|
||||||
|
{
|
||||||
logger.finest("received datagram packet - addr: "
|
logger.finest("received datagram packet - addr: "
|
||||||
+ packet.getAddress() + " port: " + packet.getPort());
|
+ packet.getAddress() + " port: " + packet.getPort());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,7 +109,7 @@ public class EventDispatcher
|
|||||||
{
|
{
|
||||||
synchronized(messageListeners)
|
synchronized(messageListeners)
|
||||||
{
|
{
|
||||||
if(!messageListeners.contains(messageListener))
|
if (!messageListeners.contains(messageListener))
|
||||||
messageListeners.add(messageListener);
|
messageListeners.add(messageListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +289,7 @@ public class EventDispatcher
|
|||||||
{
|
{
|
||||||
synchronized(messageListeners)
|
synchronized(messageListeners)
|
||||||
{
|
{
|
||||||
if(!messageListeners.isEmpty())
|
if (!messageListeners.isEmpty())
|
||||||
{
|
{
|
||||||
// there is a generic listener
|
// there is a generic listener
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -301,7 +301,8 @@ class NetAccessManager
|
|||||||
{
|
{
|
||||||
logger.log(Level.WARNING, "Removing connector:" + connector,
|
logger.log(Level.WARNING, "Removing connector:" + connector,
|
||||||
error);
|
error);
|
||||||
} else if (logger.isLoggable(Level.FINE))
|
}
|
||||||
|
else if (logger.isLoggable(Level.FINE))
|
||||||
{
|
{
|
||||||
logger.fine("Removing connector " + connector);
|
logger.fine("Removing connector " + connector);
|
||||||
}
|
}
|
||||||
@ -434,7 +435,7 @@ class NetAccessManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(connector != null)
|
if (connector != null)
|
||||||
connector.stop();
|
connector.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -306,7 +306,7 @@ public class StunClientTransaction
|
|||||||
TransactionID transactionID = getTransactionID();
|
TransactionID transactionID = getTransactionID();
|
||||||
|
|
||||||
logger.fine("handleResponse tid " + transactionID);
|
logger.fine("handleResponse tid " + transactionID);
|
||||||
if(!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE))
|
if (!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE))
|
||||||
{
|
{
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
@ -340,7 +340,7 @@ public class StunClientTransaction
|
|||||||
String maxRetransmissionsStr
|
String maxRetransmissionsStr
|
||||||
= System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS);
|
= System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS);
|
||||||
|
|
||||||
if(maxRetransmissionsStr != null
|
if (maxRetransmissionsStr != null
|
||||||
&& maxRetransmissionsStr.trim().length() > 0)
|
&& maxRetransmissionsStr.trim().length() > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -360,7 +360,7 @@ public class StunClientTransaction
|
|||||||
String originalWaitIntervalStr
|
String originalWaitIntervalStr
|
||||||
= System.getProperty(StackProperties.FIRST_CTRAN_RETRANS_AFTER);
|
= System.getProperty(StackProperties.FIRST_CTRAN_RETRANS_AFTER);
|
||||||
|
|
||||||
if(originalWaitIntervalStr != null
|
if (originalWaitIntervalStr != null
|
||||||
&& originalWaitIntervalStr.trim().length() > 0)
|
&& originalWaitIntervalStr.trim().length() > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -381,7 +381,7 @@ public class StunClientTransaction
|
|||||||
String maxWaitIntervalStr
|
String maxWaitIntervalStr
|
||||||
= System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER);
|
= System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER);
|
||||||
|
|
||||||
if(maxWaitIntervalStr != null
|
if (maxWaitIntervalStr != null
|
||||||
&& maxWaitIntervalStr.trim().length() > 0)
|
&& maxWaitIntervalStr.trim().length() > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@ -165,7 +165,8 @@ public class StunServerTransaction
|
|||||||
IOException,
|
IOException,
|
||||||
IllegalArgumentException
|
IllegalArgumentException
|
||||||
{
|
{
|
||||||
if(!isRetransmitting){
|
if (!isRetransmitting)
|
||||||
|
{
|
||||||
this.response = response;
|
this.response = response;
|
||||||
//the transaction id might already have been set, but its our job
|
//the transaction id might already have been set, but its our job
|
||||||
//to make sure of that
|
//to make sure of that
|
||||||
@ -195,7 +196,7 @@ public class StunServerTransaction
|
|||||||
{
|
{
|
||||||
//don't retransmit if we are expired or if the user application
|
//don't retransmit if we are expired or if the user application
|
||||||
//hasn't yet transmitted a first response
|
//hasn't yet transmitted a first response
|
||||||
if(isExpired() || !isRetransmitting)
|
if (isExpired() || !isRetransmitting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stackCallback.getNetAccessManager().sendMessage(
|
stackCallback.getNetAccessManager().sendMessage(
|
||||||
|
|||||||
@ -262,7 +262,7 @@ public class StunStack
|
|||||||
StunClientTransaction clientTransaction
|
StunClientTransaction clientTransaction
|
||||||
= clientTransactions.get(transactionID);
|
= clientTransactions.get(transactionID);
|
||||||
|
|
||||||
if(clientTransaction != null)
|
if (clientTransaction != null)
|
||||||
clientTransaction.cancel();
|
clientTransaction.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,7 +405,7 @@ public class StunStack
|
|||||||
*/
|
*/
|
||||||
public StunStack()
|
public StunStack()
|
||||||
{
|
{
|
||||||
this(null,null);
|
this(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -741,14 +741,14 @@ public class StunStack
|
|||||||
= TransactionID.createTransactionID(this, transactionID);
|
= TransactionID.createTransactionID(this, transactionID);
|
||||||
StunServerTransaction sTran = getServerTransaction(tid);
|
StunServerTransaction sTran = getServerTransaction(tid);
|
||||||
|
|
||||||
if(sTran == null)
|
if (sTran == null)
|
||||||
{
|
{
|
||||||
throw new StunException(StunException.TRANSACTION_DOES_NOT_EXIST,
|
throw new StunException(StunException.TRANSACTION_DOES_NOT_EXIST,
|
||||||
"The transaction specified in the response "
|
"The transaction specified in the response "
|
||||||
+ "(tid="+ tid.toString() +") "
|
+ "(tid="+ tid.toString() +") "
|
||||||
+ "object does not exist.");
|
+ "object does not exist.");
|
||||||
}
|
}
|
||||||
else if( sTran.isRetransmitting())
|
else if ( sTran.isRetransmitting())
|
||||||
{
|
{
|
||||||
throw new StunException(StunException.TRANSACTION_ALREADY_ANSWERED,
|
throw new StunException(StunException.TRANSACTION_ALREADY_ANSWERED,
|
||||||
"The transaction specified in the response "
|
"The transaction specified in the response "
|
||||||
@ -891,7 +891,7 @@ public class StunStack
|
|||||||
{
|
{
|
||||||
Message msg = ev.getMessage();
|
Message msg = ev.getMessage();
|
||||||
|
|
||||||
if(logger.isLoggable(Level.FINEST))
|
if (logger.isLoggable(Level.FINEST))
|
||||||
{
|
{
|
||||||
logger.finest(
|
logger.finest(
|
||||||
"Received a message on " + ev.getLocalAddress()
|
"Received a message on " + ev.getLocalAddress()
|
||||||
@ -899,14 +899,14 @@ public class StunStack
|
|||||||
}
|
}
|
||||||
|
|
||||||
//request
|
//request
|
||||||
if(msg instanceof Request)
|
if (msg instanceof Request)
|
||||||
{
|
{
|
||||||
logger.finest("parsing request");
|
logger.finest("parsing request");
|
||||||
|
|
||||||
TransactionID serverTid = ev.getTransactionID();
|
TransactionID serverTid = ev.getTransactionID();
|
||||||
StunServerTransaction sTran = getServerTransaction(serverTid);
|
StunServerTransaction sTran = getServerTransaction(serverTid);
|
||||||
|
|
||||||
if( sTran != null)
|
if ( sTran != null)
|
||||||
{
|
{
|
||||||
//requests from this transaction have already been seen
|
//requests from this transaction have already been seen
|
||||||
//retransmit the response if there was any
|
//retransmit the response if there was any
|
||||||
@ -925,7 +925,7 @@ public class StunStack
|
|||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Boolean.getBoolean(
|
if (!Boolean.getBoolean(
|
||||||
StackProperties.PROPAGATE_RECEIVED_RETRANSMISSIONS))
|
StackProperties.PROPAGATE_RECEIVED_RETRANSMISSIONS))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -982,7 +982,7 @@ public class StunStack
|
|||||||
logger.log(Level.INFO, "Received an invalid request.", t);
|
logger.log(Level.INFO, "Received an invalid request.", t);
|
||||||
Throwable cause = t.getCause();
|
Throwable cause = t.getCause();
|
||||||
|
|
||||||
if(((t instanceof StunException)
|
if (((t instanceof StunException)
|
||||||
&& ((StunException) t).getID()
|
&& ((StunException) t).getID()
|
||||||
== StunException
|
== StunException
|
||||||
.TRANSACTION_ALREADY_ANSWERED)
|
.TRANSACTION_ALREADY_ANSWERED)
|
||||||
@ -996,7 +996,7 @@ public class StunStack
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(t instanceof IllegalArgumentException)
|
if (t instanceof IllegalArgumentException)
|
||||||
{
|
{
|
||||||
error
|
error
|
||||||
= createCorrespondingErrorResponse(
|
= createCorrespondingErrorResponse(
|
||||||
@ -1030,12 +1030,12 @@ public class StunStack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//response
|
//response
|
||||||
else if(msg instanceof Response)
|
else if (msg instanceof Response)
|
||||||
{
|
{
|
||||||
TransactionID tid = ev.getTransactionID();
|
TransactionID tid = ev.getTransactionID();
|
||||||
StunClientTransaction tran = clientTransactions.remove(tid);
|
StunClientTransaction tran = clientTransactions.remove(tid);
|
||||||
|
|
||||||
if(tran != null)
|
if (tran != null)
|
||||||
{
|
{
|
||||||
tran.handleResponse(ev);
|
tran.handleResponse(ev);
|
||||||
}
|
}
|
||||||
@ -1193,7 +1193,7 @@ public class StunStack
|
|||||||
"Wrong MESSAGE-INTEGRITY value.");
|
"Wrong MESSAGE-INTEGRITY value.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Boolean.getBoolean(StackProperties.REQUIRE_MESSAGE_INTEGRITY))
|
else if (Boolean.getBoolean(StackProperties.REQUIRE_MESSAGE_INTEGRITY))
|
||||||
{
|
{
|
||||||
// no message integrity
|
// no message integrity
|
||||||
Response error = createCorrespondingErrorResponse(
|
Response error = createCorrespondingErrorResponse(
|
||||||
@ -1211,9 +1211,9 @@ public class StunStack
|
|||||||
//look for unknown attributes.
|
//look for unknown attributes.
|
||||||
List<Attribute> allAttributes = request.getAttributes();
|
List<Attribute> allAttributes = request.getAttributes();
|
||||||
StringBuffer sBuff = new StringBuffer();
|
StringBuffer sBuff = new StringBuffer();
|
||||||
for(Attribute attr : allAttributes)
|
for (Attribute attr : allAttributes)
|
||||||
{
|
{
|
||||||
if(attr instanceof OptionalAttribute
|
if (attr instanceof OptionalAttribute
|
||||||
&& attr.getAttributeType()
|
&& attr.getAttributeType()
|
||||||
< Attribute.UNKNOWN_OPTIONAL_ATTRIBUTE)
|
< Attribute.UNKNOWN_OPTIONAL_ATTRIBUTE)
|
||||||
sBuff.append(attr.getAttributeType());
|
sBuff.append(attr.getAttributeType());
|
||||||
@ -1264,7 +1264,7 @@ public class StunStack
|
|||||||
|| (shortTermCredentialMechanism
|
|| (shortTermCredentialMechanism
|
||||||
&& ((colon = username.indexOf(":")) < 1)))
|
&& ((colon = username.indexOf(":")) < 1)))
|
||||||
{
|
{
|
||||||
if(logger.isLoggable(Level.FINE))
|
if (logger.isLoggable(Level.FINE))
|
||||||
{
|
{
|
||||||
logger.log(Level.FINE, "Received a message with an improperly "
|
logger.log(Level.FINE, "Received a message with an improperly "
|
||||||
+"formatted username");
|
+"formatted username");
|
||||||
@ -1277,7 +1277,7 @@ public class StunStack
|
|||||||
|
|
||||||
byte[] key = getCredentialsManager().getLocalKey(username);
|
byte[] key = getCredentialsManager().getLocalKey(username);
|
||||||
|
|
||||||
if(key == null)
|
if (key == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1323,7 +1323,7 @@ public class StunStack
|
|||||||
expectedMsgIntHmacSha1Content,
|
expectedMsgIntHmacSha1Content,
|
||||||
msgIntHmacSha1Content))
|
msgIntHmacSha1Content))
|
||||||
{
|
{
|
||||||
if(logger.isLoggable(Level.FINE))
|
if (logger.isLoggable(Level.FINE))
|
||||||
{
|
{
|
||||||
logger.log(
|
logger.log(
|
||||||
Level.FINE,
|
Level.FINE,
|
||||||
@ -1391,7 +1391,7 @@ public class StunStack
|
|||||||
|
|
||||||
if ((username.length() < 1) || (colon < 1))
|
if ((username.length() < 1) || (colon < 1))
|
||||||
{
|
{
|
||||||
if(logger.isLoggable(Level.FINE))
|
if (logger.isLoggable(Level.FINE))
|
||||||
{
|
{
|
||||||
logger.log(Level.FINE, "Received a message with an improperly "
|
logger.log(Level.FINE, "Received a message with an improperly "
|
||||||
+"formatted username");
|
+"formatted username");
|
||||||
@ -1444,7 +1444,7 @@ public class StunStack
|
|||||||
* @return corresponding Error Response object.
|
* @return corresponding Error Response object.
|
||||||
*/
|
*/
|
||||||
public Response createCorrespondingErrorResponse(char requestType,
|
public Response createCorrespondingErrorResponse(char requestType,
|
||||||
char errorCode, String reasonPhrase,char... unknownAttributes)
|
char errorCode, String reasonPhrase, char... unknownAttributes)
|
||||||
{
|
{
|
||||||
if (requestType == Message.BINDING_REQUEST)
|
if (requestType == Message.BINDING_REQUEST)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -125,11 +125,11 @@ public class TransactionID
|
|||||||
*/
|
*/
|
||||||
private static void generateTransactionID(TransactionID tid, int nb)
|
private static void generateTransactionID(TransactionID tid, int nb)
|
||||||
{
|
{
|
||||||
long left = System.currentTimeMillis();//the first nb/2 bytes of the id
|
long left = System.currentTimeMillis(); //the first nb/2 bytes of the id
|
||||||
long right = random.nextLong();//the last nb/2 bytes of the id
|
long right = random.nextLong(); //the last nb/2 bytes of the id
|
||||||
int b = nb / 2;
|
int b = nb / 2;
|
||||||
|
|
||||||
for(int i = 0; i < b; i++)
|
for (int i = 0; i < b; i++)
|
||||||
{
|
{
|
||||||
tid.transactionID[i] = (byte)((left >> (i * 8)) & 0xFFL);
|
tid.transactionID[i] = (byte)((left >> (i * 8)) & 0xFFL);
|
||||||
tid.transactionID[i + b] = (byte)((right >> (i * 8)) & 0xFFL);
|
tid.transactionID[i + b] = (byte)((right >> (i * 8)) & 0xFFL);
|
||||||
@ -166,13 +166,13 @@ public class TransactionID
|
|||||||
StunClientTransaction cliTran
|
StunClientTransaction cliTran
|
||||||
= stunStack.getClientTransaction(transactionID);
|
= stunStack.getClientTransaction(transactionID);
|
||||||
|
|
||||||
if(cliTran != null)
|
if (cliTran != null)
|
||||||
return cliTran.getTransactionID();
|
return cliTran.getTransactionID();
|
||||||
|
|
||||||
StunServerTransaction serTran
|
StunServerTransaction serTran
|
||||||
= stunStack.getServerTransaction(transactionID);
|
= stunStack.getServerTransaction(transactionID);
|
||||||
|
|
||||||
if(serTran != null)
|
if (serTran != null)
|
||||||
return serTran.getTransactionID();
|
return serTran.getTransactionID();
|
||||||
|
|
||||||
//seems that the caller really wants a new ID
|
//seems that the caller really wants a new ID
|
||||||
@ -219,9 +219,9 @@ public class TransactionID
|
|||||||
*/
|
*/
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if(this == obj)
|
if (this == obj)
|
||||||
return true;
|
return true;
|
||||||
if(!(obj instanceof TransactionID))
|
if (!(obj instanceof TransactionID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
byte targetBytes[] = ((TransactionID)obj).transactionID;
|
byte targetBytes[] = ((TransactionID)obj).transactionID;
|
||||||
@ -272,10 +272,10 @@ public class TransactionID
|
|||||||
StringBuilder idStr = new StringBuilder();
|
StringBuilder idStr = new StringBuilder();
|
||||||
|
|
||||||
idStr.append("0x");
|
idStr.append("0x");
|
||||||
for(int i = 0; i < transactionID.length; i++)
|
for (int i = 0; i < transactionID.length; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if((transactionID[i] & 0xFF) <= 15)
|
if ((transactionID[i] & 0xFF) <= 15)
|
||||||
idStr.append("0");
|
idStr.append("0");
|
||||||
|
|
||||||
idStr.append(
|
idStr.append(
|
||||||
|
|||||||
@ -168,7 +168,7 @@ public class BlockingRequestSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
ended = false;
|
ended = false;
|
||||||
while(!ended)
|
while (!ended)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -212,11 +212,11 @@ public class BlockingRequestSender
|
|||||||
synchronized(sendLock)
|
synchronized(sendLock)
|
||||||
{
|
{
|
||||||
stunStack.sendRequest(request, serverAddress, localAddress,
|
stunStack.sendRequest(request, serverAddress, localAddress,
|
||||||
BlockingRequestSender.this,tranID);
|
BlockingRequestSender.this, tranID);
|
||||||
}
|
}
|
||||||
|
|
||||||
ended = false;
|
ended = false;
|
||||||
while(!ended)
|
while (!ended)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@ -201,7 +201,7 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
StunDiscoveryReport report = new StunDiscoveryReport();
|
StunDiscoveryReport report = new StunDiscoveryReport();
|
||||||
StunMessageEvent evt = doTestI(serverAddress);
|
StunMessageEvent evt = doTestI(serverAddress);
|
||||||
|
|
||||||
if(evt == null)
|
if (evt == null)
|
||||||
{
|
{
|
||||||
//UDP Blocked
|
//UDP Blocked
|
||||||
report.setNatType(StunDiscoveryReport.UDP_BLOCKING_FIREWALL);
|
report.setNatType(StunDiscoveryReport.UDP_BLOCKING_FIREWALL);
|
||||||
@ -213,7 +213,7 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
=((MappedAddressAttribute)evt.getMessage()
|
=((MappedAddressAttribute)evt.getMessage()
|
||||||
.getAttribute(Attribute.MAPPED_ADDRESS)).getAddress();
|
.getAttribute(Attribute.MAPPED_ADDRESS)).getAddress();
|
||||||
|
|
||||||
if(mappedAddress == null)
|
if (mappedAddress == null)
|
||||||
{
|
{
|
||||||
/* maybe we contact a STUNbis server and which do not
|
/* maybe we contact a STUNbis server and which do not
|
||||||
* understand our request.
|
* understand our request.
|
||||||
@ -257,7 +257,7 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
if (evt == null)
|
if (evt == null)
|
||||||
{
|
{
|
||||||
evt = doTestI(backupServerAddress);
|
evt = doTestI(backupServerAddress);
|
||||||
if(evt == null)
|
if (evt == null)
|
||||||
{
|
{
|
||||||
logger.info("Failed to receive a response from "
|
logger.info("Failed to receive a response from "
|
||||||
+"backup stun server!");
|
+"backup stun server!");
|
||||||
@ -267,10 +267,10 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
((MappedAddressAttribute)evt.getMessage().
|
((MappedAddressAttribute)evt.getMessage().
|
||||||
getAttribute(Attribute.MAPPED_ADDRESS))
|
getAttribute(Attribute.MAPPED_ADDRESS))
|
||||||
.getAddress();
|
.getAddress();
|
||||||
if(mappedAddress.equals(mappedAddress2))
|
if (mappedAddress.equals(mappedAddress2))
|
||||||
{
|
{
|
||||||
evt = doTestIII(serverAddress);
|
evt = doTestIII(serverAddress);
|
||||||
if(evt == null)
|
if (evt == null)
|
||||||
{
|
{
|
||||||
//port restricted cone
|
//port restricted cone
|
||||||
report.setNatType(StunDiscoveryReport
|
report.setNatType(StunDiscoveryReport
|
||||||
@ -350,7 +350,7 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(evt != null)
|
if (evt != null)
|
||||||
logger.fine("TEST I res="+evt.getRemoteAddress().toString()
|
logger.fine("TEST I res="+evt.getRemoteAddress().toString()
|
||||||
+" - "+ evt.getRemoteAddress().getHostAddress());
|
+" - "+ evt.getRemoteAddress().getHostAddress());
|
||||||
else
|
else
|
||||||
@ -385,7 +385,7 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
StunMessageEvent evt
|
StunMessageEvent evt
|
||||||
= requestSender.sendRequestAndWaitForResponse(request,
|
= requestSender.sendRequestAndWaitForResponse(request,
|
||||||
serverAddress);
|
serverAddress);
|
||||||
if(evt != null)
|
if (evt != null)
|
||||||
logger.fine("Test II res="+evt.getRemoteAddress().toString()
|
logger.fine("Test II res="+evt.getRemoteAddress().toString()
|
||||||
+" - "+ evt.getRemoteAddress().getHostAddress());
|
+" - "+ evt.getRemoteAddress().getHostAddress());
|
||||||
else
|
else
|
||||||
@ -409,7 +409,8 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
{
|
{
|
||||||
Request request = MessageFactory.createBindingRequest();
|
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 */
|
/* add a change request attribute */
|
||||||
ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute();
|
ChangeRequestAttribute changeRequest = AttributeFactory.createChangeRequestAttribute();
|
||||||
changeRequest.setChangeIpFlag(false);
|
changeRequest.setChangeIpFlag(false);
|
||||||
@ -418,7 +419,7 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
|
|
||||||
StunMessageEvent evt = requestSender.sendRequestAndWaitForResponse(
|
StunMessageEvent evt = requestSender.sendRequestAndWaitForResponse(
|
||||||
request, serverAddress);
|
request, serverAddress);
|
||||||
if(evt != null)
|
if (evt != null)
|
||||||
logger.fine("Test III res="+evt.getRemoteAddress().toString()
|
logger.fine("Test III res="+evt.getRemoteAddress().toString()
|
||||||
+" - "+ evt.getRemoteAddress().getHostAddress());
|
+" - "+ evt.getRemoteAddress().getHostAddress());
|
||||||
else
|
else
|
||||||
@ -435,7 +436,7 @@ public class NetworkConfigurationDiscoveryProcess
|
|||||||
private void checkStarted()
|
private void checkStarted()
|
||||||
throws StunException
|
throws StunException
|
||||||
{
|
{
|
||||||
if(!started)
|
if (!started)
|
||||||
throw new StunException(StunException.ILLEGAL_STATE,
|
throw new StunException(StunException.ILLEGAL_STATE,
|
||||||
"The Discoverer must be started before "
|
"The Discoverer must be started before "
|
||||||
+"launching the discovery process!");
|
+"launching the discovery process!");
|
||||||
|
|||||||
@ -137,14 +137,14 @@ public class SimpleAddressDetector
|
|||||||
stunStack.removeSocket(localAddress);
|
stunStack.removeSocket(localAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(evt != null)
|
if (evt != null)
|
||||||
{
|
{
|
||||||
Response res = (Response)evt.getMessage();
|
Response res = (Response)evt.getMessage();
|
||||||
|
|
||||||
/* in classic STUN, the response contains a MAPPED-ADDRESS */
|
/* in classic STUN, the response contains a MAPPED-ADDRESS */
|
||||||
MappedAddressAttribute maAtt = (MappedAddressAttribute)
|
MappedAddressAttribute maAtt = (MappedAddressAttribute)
|
||||||
res.getAttribute(Attribute.MAPPED_ADDRESS);
|
res.getAttribute(Attribute.MAPPED_ADDRESS);
|
||||||
if(maAtt != null)
|
if (maAtt != null)
|
||||||
{
|
{
|
||||||
return maAtt.getAddress();
|
return maAtt.getAddress();
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ public class SimpleAddressDetector
|
|||||||
/* in STUN bis, the response contains a XOR-MAPPED-ADDRESS */
|
/* in STUN bis, the response contains a XOR-MAPPED-ADDRESS */
|
||||||
XorMappedAddressAttribute xorAtt = (XorMappedAddressAttribute)res
|
XorMappedAddressAttribute xorAtt = (XorMappedAddressAttribute)res
|
||||||
.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
|
.getAttribute(Attribute.XOR_MAPPED_ADDRESS);
|
||||||
if(xorAtt != null)
|
if (xorAtt != null)
|
||||||
{
|
{
|
||||||
byte xoring[] = new byte[16];
|
byte xoring[] = new byte[16];
|
||||||
|
|
||||||
|
|||||||
@ -129,10 +129,10 @@ public class StunDiscoveryReport
|
|||||||
*/
|
*/
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
if(! (obj instanceof StunDiscoveryReport))
|
if (! (obj instanceof StunDiscoveryReport))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
StunDiscoveryReport target = (StunDiscoveryReport)obj;
|
StunDiscoveryReport target = (StunDiscoveryReport)obj;
|
||||||
|
|||||||
@ -68,10 +68,10 @@ public class Ice4jLogFormatter
|
|||||||
int lineNumber = inferCaller(record);
|
int lineNumber = inferCaller(record);
|
||||||
String loggerName = record.getLoggerName();
|
String loggerName = record.getLoggerName();
|
||||||
|
|
||||||
if(loggerName == null)
|
if (loggerName == null)
|
||||||
loggerName = record.getSourceClassName();
|
loggerName = record.getSourceClassName();
|
||||||
|
|
||||||
if(loggerName.startsWith("net.java.sip.communicator."))
|
if (loggerName.startsWith("net.java.sip.communicator."))
|
||||||
{
|
{
|
||||||
sb.append(loggerName.substring("net.java.sip.communicator."
|
sb.append(loggerName.substring("net.java.sip.communicator."
|
||||||
.length()));
|
.length()));
|
||||||
@ -85,7 +85,7 @@ public class Ice4jLogFormatter
|
|||||||
sb.append(record.getSourceMethodName());
|
sb.append(record.getSourceMethodName());
|
||||||
|
|
||||||
//include the line number if we have it.
|
//include the line number if we have it.
|
||||||
if(lineNumber != -1)
|
if (lineNumber != -1)
|
||||||
sb.append("().").append(Integer.toString(lineNumber));
|
sb.append("().").append(Integer.toString(lineNumber));
|
||||||
else
|
else
|
||||||
sb.append("()");
|
sb.append("()");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user