libs/jstun-android.patch
changeset 648 6dd33a633ddc
parent 647 c88a6d0911ad
parent 646 49e83a4b67b9
child 649 e29937c5670c
equal deleted inserted replaced
647:c88a6d0911ad 648:6dd33a633ddc
     1 diff -Nru src-stun/de/javawi/jstun/attribute/ChangedAddress.java src/de/javawi/jstun/attribute/ChangedAddress.java
       
     2 --- src-stun/de/javawi/jstun/attribute/ChangedAddress.java	2009-03-08 13:37:27.000000000 +0100
       
     3 +++ src/de/javawi/jstun/attribute/ChangedAddress.java	2009-10-03 14:47:30.504972058 +0200
       
     4 @@ -11,11 +11,9 @@
       
     5  
       
     6  package de.javawi.jstun.attribute;
       
     7  
       
     8 -import org.slf4j.Logger;
       
     9 -import org.slf4j.LoggerFactory;
       
    10 +import android.util.Log;
       
    11  
       
    12  public class ChangedAddress extends MappedResponseChangedSourceAddressReflectedFrom {
       
    13 -	private static final Logger LOGGER = LoggerFactory.getLogger(ChangedAddress.class);
       
    14  	
       
    15  	public ChangedAddress() {
       
    16  		super(MessageAttribute.MessageAttributeType.ChangedAddress);
       
    17 @@ -24,7 +22,7 @@
       
    18  	public static MessageAttribute parse(byte[] data) throws MessageAttributeParsingException {
       
    19  		ChangedAddress ca = new ChangedAddress();
       
    20  		MappedResponseChangedSourceAddressReflectedFrom.parse(ca, data);
       
    21 -		LOGGER.debug("Message Attribute: Changed Address parsed: " + ca.toString() + ".");
       
    22 +		Log.d("Jstun-ChangedAddress", "Message Attribute: Changed Address parsed: " + ca.toString() + ".");
       
    23  		return ca;
       
    24  	}
       
    25  }
       
    26 diff -Nru src-stun/de/javawi/jstun/attribute/MappedAddress.java src/de/javawi/jstun/attribute/MappedAddress.java
       
    27 --- src-stun/de/javawi/jstun/attribute/MappedAddress.java	2009-03-08 13:36:42.000000000 +0100
       
    28 +++ src/de/javawi/jstun/attribute/MappedAddress.java	2009-10-03 14:47:23.989081351 +0200
       
    29 @@ -11,11 +11,9 @@
       
    30  
       
    31  package de.javawi.jstun.attribute;
       
    32  
       
    33 -import org.slf4j.Logger;
       
    34 -import org.slf4j.LoggerFactory;
       
    35 +import android.util.Log;
       
    36  
       
    37  public class MappedAddress extends MappedResponseChangedSourceAddressReflectedFrom {
       
    38 -	private static final Logger LOGGER = LoggerFactory.getLogger(MappedAddress.class);
       
    39  	public MappedAddress() {
       
    40  		super(MessageAttribute.MessageAttributeType.MappedAddress);
       
    41  	}
       
    42 @@ -23,7 +21,7 @@
       
    43  	public static MessageAttribute parse(byte[] data) throws MessageAttributeParsingException {
       
    44  		MappedAddress ma = new MappedAddress();
       
    45  		MappedResponseChangedSourceAddressReflectedFrom.parse(ma, data);
       
    46 -		LOGGER.debug("Message Attribute: Mapped Address parsed: " + ma.toString() + ".");
       
    47 +		Log.d("Jstun-MappedAddress", "Message Attribute: Mapped Address parsed: " + ma.toString() + ".");
       
    48  		return ma;
       
    49  	}
       
    50  }
       
    51 diff -Nru src-stun/de/javawi/jstun/attribute/MessageAttribute.java src/de/javawi/jstun/attribute/MessageAttribute.java
       
    52 --- src-stun/de/javawi/jstun/attribute/MessageAttribute.java	2009-03-08 13:35:52.000000000 +0100
       
    53 +++ src/de/javawi/jstun/attribute/MessageAttribute.java	2009-10-03 14:48:48.776972620 +0200
       
    54 @@ -11,15 +11,12 @@
       
    55  
       
    56  package de.javawi.jstun.attribute;
       
    57  
       
    58 -import org.slf4j.Logger;
       
    59 -import org.slf4j.LoggerFactory;
       
    60 -
       
    61 +import android.util.Log;
       
    62  import de.javawi.jstun.util.Utility;
       
    63  import de.javawi.jstun.util.UtilityException;
       
    64  
       
    65  
       
    66  public abstract class MessageAttribute implements MessageAttributeInterface {
       
    67 -	private static final Logger LOGGER = LoggerFactory.getLogger(MessageAttribute.class);
       
    68  	MessageAttributeType type;
       
    69  	
       
    70  	public MessageAttribute() {
       
    71 @@ -104,7 +101,7 @@
       
    72  				if (type <= 0x7fff) {
       
    73  					throw new UnknownMessageAttributeException("Unkown mandatory message attribute", intToType(type));
       
    74  				} else {
       
    75 -					LOGGER.debug("MessageAttribute with type " + type + " unkown.");
       
    76 +					Log.d("Jstun-MessageAttribute", "MessageAttribute with type " + type + " unkown.");
       
    77  					ma = Dummy.parse(valueArray);
       
    78  					break;
       
    79  				}
       
    80 diff -Nru src-stun/de/javawi/jstun/attribute/ReflectedFrom.java src/de/javawi/jstun/attribute/ReflectedFrom.java
       
    81 --- src-stun/de/javawi/jstun/attribute/ReflectedFrom.java	2009-03-08 13:34:16.000000000 +0100
       
    82 +++ src/de/javawi/jstun/attribute/ReflectedFrom.java	2009-10-03 14:48:06.624977962 +0200
       
    83 @@ -11,11 +11,9 @@
       
    84  
       
    85  package de.javawi.jstun.attribute;
       
    86  
       
    87 -import org.slf4j.Logger;
       
    88 -import org.slf4j.LoggerFactory;
       
    89 +import android.util.Log;
       
    90  
       
    91  public class ReflectedFrom extends MappedResponseChangedSourceAddressReflectedFrom {
       
    92 -	private static final Logger LOGGER = LoggerFactory.getLogger(ReflectedFrom.class);
       
    93  	
       
    94  	public ReflectedFrom() {
       
    95  		super(MessageAttribute.MessageAttributeType.ReflectedFrom);
       
    96 @@ -24,7 +22,7 @@
       
    97  	public static ReflectedFrom parse(byte[] data) throws MessageAttributeParsingException {
       
    98  		ReflectedFrom result = new ReflectedFrom();
       
    99  		MappedResponseChangedSourceAddressReflectedFrom.parse(result, data);
       
   100 -		LOGGER.debug("Message Attribute: ReflectedFrom parsed: " + result.toString() + ".");
       
   101 +		Log.d("Jstun-ReflectedFrom", "Message Attribute: ReflectedFrom parsed: " + result.toString() + ".");
       
   102  		return result;
       
   103  	}
       
   104  
       
   105 diff -Nru src-stun/de/javawi/jstun/attribute/ResponseAddress.java src/de/javawi/jstun/attribute/ResponseAddress.java
       
   106 --- src-stun/de/javawi/jstun/attribute/ResponseAddress.java	2009-03-08 13:35:02.000000000 +0100
       
   107 +++ src/de/javawi/jstun/attribute/ResponseAddress.java	2009-10-03 14:49:42.388979100 +0200
       
   108 @@ -11,12 +11,9 @@
       
   109  
       
   110  package de.javawi.jstun.attribute;
       
   111  
       
   112 -import org.slf4j.Logger;
       
   113 -import org.slf4j.LoggerFactory;
       
   114 -
       
   115 +import android.util.Log;
       
   116  
       
   117  public class ResponseAddress extends MappedResponseChangedSourceAddressReflectedFrom {
       
   118 -	private static final Logger LOGGER = LoggerFactory.getLogger(ResponseAddress.class);
       
   119  	public ResponseAddress() {
       
   120  		super(MessageAttribute.MessageAttributeType.ResponseAddress);
       
   121  	}
       
   122 @@ -24,7 +21,7 @@
       
   123  	public static MessageAttribute parse(byte[] data) throws MessageAttributeParsingException {
       
   124  		ResponseAddress ra = new ResponseAddress();
       
   125  		MappedResponseChangedSourceAddressReflectedFrom.parse(ra, data);
       
   126 -		LOGGER.debug("Message Attribute: Response Address parsed: " + ra.toString() + ".");
       
   127 +		Log.d("Jstun-ResponseAddress", "Message Attribute: Response Address parsed: " + ra.toString() + ".");
       
   128  		return ra;
       
   129  	}
       
   130  }
       
   131 diff -Nru src-stun/de/javawi/jstun/attribute/SourceAddress.java src/de/javawi/jstun/attribute/SourceAddress.java
       
   132 --- src-stun/de/javawi/jstun/attribute/SourceAddress.java	2009-03-08 13:33:15.000000000 +0100
       
   133 +++ src/de/javawi/jstun/attribute/SourceAddress.java	2009-10-03 14:50:35.312972305 +0200
       
   134 @@ -11,12 +11,9 @@
       
   135  
       
   136  package de.javawi.jstun.attribute;
       
   137  
       
   138 -import org.slf4j.Logger;
       
   139 -import org.slf4j.LoggerFactory;
       
   140 -
       
   141 +import android.util.Log;
       
   142  
       
   143  public class SourceAddress extends MappedResponseChangedSourceAddressReflectedFrom {
       
   144 -	private static final Logger LOGGER = LoggerFactory.getLogger(SourceAddress.class);
       
   145  	public SourceAddress() {
       
   146  		super(MessageAttribute.MessageAttributeType.SourceAddress);
       
   147  	}
       
   148 @@ -24,7 +21,7 @@
       
   149  	public static MessageAttribute parse(byte[] data) throws MessageAttributeParsingException {
       
   150  		SourceAddress sa = new SourceAddress();
       
   151  		MappedResponseChangedSourceAddressReflectedFrom.parse(sa, data);
       
   152 -		LOGGER.debug("Message Attribute: Source Address parsed: " + sa.toString() + ".");
       
   153 +		Log.d("Jstun-SourceAddress", "Message Attribute: Source Address parsed: " + sa.toString() + ".");
       
   154  		return sa;
       
   155  	}
       
   156  }
       
   157 \ No newline at end of file
       
   158 diff -Nru src-stun/de/javawi/jstun/header/MessageHeader.java src/de/javawi/jstun/header/MessageHeader.java
       
   159 --- src-stun/de/javawi/jstun/header/MessageHeader.java	2009-03-08 13:54:30.000000000 +0100
       
   160 +++ src/de/javawi/jstun/header/MessageHeader.java	2009-10-03 14:52:58.156973579 +0200
       
   161 @@ -14,8 +14,7 @@
       
   162  import java.util.Iterator;
       
   163  import java.util.TreeMap;
       
   164  
       
   165 -import org.slf4j.Logger;
       
   166 -import org.slf4j.LoggerFactory;
       
   167 +import android.util.Log;
       
   168  
       
   169  import de.javawi.jstun.attribute.MessageAttribute;
       
   170  import de.javawi.jstun.attribute.MessageAttributeParsingException;
       
   171 @@ -38,7 +37,6 @@
       
   172       *                                                                 |
       
   173       * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   174  	 */
       
   175 -	private static final Logger LOGGER = LoggerFactory.getLogger(MessageHeader.class);
       
   176  	MessageHeaderType type;
       
   177  	byte[] id = new byte[16];
       
   178  	
       
   179 @@ -169,12 +167,12 @@
       
   180  			System.arraycopy(data, 0, typeArray, 0, 2);
       
   181  			int type = Utility.twoBytesToInteger(typeArray);
       
   182  			switch (type) {
       
   183 -				case BINDINGREQUEST: mh.setType(MessageHeaderType.BindingRequest); LOGGER.debug("Binding Request received."); break;
       
   184 -				case BINDINGRESPONSE: mh.setType(MessageHeaderType.BindingResponse); LOGGER.debug("Binding Response received."); break;
       
   185 -				case BINDINGERRORRESPONSE: mh.setType(MessageHeaderType.BindingErrorResponse); LOGGER.debug("Binding Error Response received."); break;
       
   186 -				case SHAREDSECRETREQUEST: mh.setType(MessageHeaderType.SharedSecretRequest); LOGGER.debug("Shared Secret Request received."); break;
       
   187 -				case SHAREDSECRETRESPONSE: mh.setType(MessageHeaderType.SharedSecretResponse); LOGGER.debug("Shared Secret Response received."); break;
       
   188 -				case SHAREDSECRETERRORRESPONSE: mh.setType(MessageHeaderType.SharedSecretErrorResponse); LOGGER.debug("Shared Secret Error Response received.");break;
       
   189 +				case BINDINGREQUEST: mh.setType(MessageHeaderType.BindingRequest); Log.d("Jstun-MessageHeader", "Binding Request received."); break;
       
   190 +				case BINDINGRESPONSE: mh.setType(MessageHeaderType.BindingResponse); Log.d("Jstun-MessageHeader", "Binding Response received."); break;
       
   191 +				case BINDINGERRORRESPONSE: mh.setType(MessageHeaderType.BindingErrorResponse); Log.d("Jstun-MessageHeader", "Binding Error Response received."); break;
       
   192 +				case SHAREDSECRETREQUEST: mh.setType(MessageHeaderType.SharedSecretRequest); Log.d("Jstun-MessageHeader", "Shared Secret Request received."); break;
       
   193 +				case SHAREDSECRETRESPONSE: mh.setType(MessageHeaderType.SharedSecretResponse); Log.d("Jstun-MessageHeader", "Shared Secret Response received."); break;
       
   194 +				case SHAREDSECRETERRORRESPONSE: mh.setType(MessageHeaderType.SharedSecretErrorResponse); Log.d("Jstun-MessageHeader", "Shared Secret Error Response received.");break;
       
   195  				default: throw new MessageHeaderParsingException("Message type " + type + "is not supported"); 
       
   196  			}
       
   197  			return mh;
       
   198 diff -Nru src-stun/de/javawi/jstun/test/BindingLifetimeTest.java src/de/javawi/jstun/test/BindingLifetimeTest.java
       
   199 --- src-stun/de/javawi/jstun/test/BindingLifetimeTest.java	2009-03-08 13:43:27.000000000 +0100
       
   200 +++ src/de/javawi/jstun/test/BindingLifetimeTest.java	2009-10-03 14:55:31.104990854 +0200
       
   201 @@ -21,8 +21,8 @@
       
   202  import java.util.Timer;
       
   203  import java.util.TimerTask;
       
   204  
       
   205 -import org.slf4j.Logger;
       
   206 -import org.slf4j.LoggerFactory;
       
   207 +import android.util.Log;
       
   208 +
       
   209  
       
   210  import de.javawi.jstun.attribute.ChangeRequest;
       
   211  import de.javawi.jstun.attribute.ErrorCode;
       
   212 @@ -36,7 +36,6 @@
       
   213  import de.javawi.jstun.util.UtilityException;
       
   214  
       
   215  public class BindingLifetimeTest {
       
   216 -	private static final Logger LOGGER = LoggerFactory.getLogger(BindingLifetimeTest.class);
       
   217  	String stunServer;
       
   218  	int port;
       
   219  	int timeout = 300; //ms
       
   220 @@ -70,7 +69,7 @@
       
   221  		}
       
   222  		BindingLifetimeTask task = new BindingLifetimeTask();
       
   223  		timer.schedule(task, binarySearchLifetime);
       
   224 -		LOGGER.debug("Timer scheduled initially: " + binarySearchLifetime + ".");
       
   225 +		Log.d("Jstun-BindingLifetimeTest", "Timer scheduled initially: " + binarySearchLifetime + ".");
       
   226  	}
       
   227  	
       
   228  	private boolean bindingCommunicationInitialSocket() throws UtilityException, IOException, MessageHeaderParsingException, MessageAttributeParsingException {
       
   229 @@ -82,7 +81,7 @@
       
   230  		
       
   231  		DatagramPacket send = new DatagramPacket(data, data.length, InetAddress.getByName(stunServer), port);
       
   232  		initialSocket.send(send);
       
   233 -		LOGGER.debug("Binding Request sent.");
       
   234 +		Log.d("Jstun-BindingLifetimeTest", "Binding Request sent.");
       
   235  	
       
   236  		MessageHeader receiveMH = new MessageHeader();
       
   237  		while (!(receiveMH.equalTransactionID(sendMH))) {
       
   238 @@ -94,11 +93,11 @@
       
   239  		ma = (MappedAddress) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.MappedAddress);
       
   240  		ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode);
       
   241  		if (ec != null) {
       
   242 -			LOGGER.debug("Message header contains an Errorcode message attribute.");
       
   243 +			Log.d("Jstun-BindingLifetimeTest", "Message header contains an Errorcode message attribute.");
       
   244  			return true;
       
   245  		}
       
   246  		if (ma == null) {
       
   247 -			LOGGER.debug("Response does not contain a Mapped Address message attribute.");
       
   248 +			Log.d("Jstun-BindingLifetimeTest", "Response does not contain a Mapped Address message attribute.");
       
   249  			return true;
       
   250  		}
       
   251  		return false;
       
   252 @@ -127,7 +126,7 @@
       
   253  			try {
       
   254  				lifetimeQuery();
       
   255  			} catch (Exception e) {
       
   256 -				LOGGER.debug("Unhandled Exception. BindLifetimeTasks stopped.");
       
   257 +				Log.d("Jstun-BindingLifetimeTest", "Unhandled Exception. BindLifetimeTasks stopped.");
       
   258  				e.printStackTrace();
       
   259  			}
       
   260  		}
       
   261 @@ -150,7 +149,7 @@
       
   262  			
       
   263  				DatagramPacket send = new DatagramPacket(data, data.length, InetAddress.getByName(stunServer), port);
       
   264  				socket.send(send);
       
   265 -				LOGGER.debug("Binding Request sent.");
       
   266 +				Log.d("Jstun-BindingLifetimeTest", "Binding Request sent.");
       
   267  		
       
   268  				MessageHeader receiveMH = new MessageHeader();
       
   269  				while (!(receiveMH.equalTransactionID(sendMH))) {
       
   270 @@ -161,30 +160,30 @@
       
   271  				}
       
   272  				ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode);
       
   273  				if (ec != null) {
       
   274 -					LOGGER.debug("Message header contains errorcode message attribute.");
       
   275 +					Log.d("Jstun-BindingLifetimeTest", "Message header contains errorcode message attribute.");
       
   276  					return;
       
   277  				}
       
   278 -				LOGGER.debug("Binding Response received.");
       
   279 +				Log.d("Jstun-BindingLifetimeTest", "Binding Response received.");
       
   280  				if (upperBinarySearchLifetime == (lowerBinarySearchLifetime + 1)) {
       
   281 -					LOGGER.debug("BindingLifetimeTest completed. UDP binding lifetime: " + binarySearchLifetime + ".");
       
   282 +					Log.d("Jstun-BindingLifetimeTest", "BindingLifetimeTest completed. UDP binding lifetime: " + binarySearchLifetime + ".");
       
   283  					completed = true;
       
   284  					return;
       
   285  				}
       
   286  				lifetime = binarySearchLifetime;
       
   287 -				LOGGER.debug("Lifetime update: " + lifetime + ".");
       
   288 +				Log.d("Jstun-BindingLifetimeTest", "Lifetime update: " + lifetime + ".");
       
   289  				lowerBinarySearchLifetime = binarySearchLifetime;
       
   290  				binarySearchLifetime = (upperBinarySearchLifetime + lowerBinarySearchLifetime) / 2;
       
   291  				if (binarySearchLifetime > 0) {
       
   292  					BindingLifetimeTask task = new BindingLifetimeTask();
       
   293  					timer.schedule(task, binarySearchLifetime);
       
   294 -					LOGGER.debug("Timer scheduled: " + binarySearchLifetime + ".");
       
   295 +					Log.d("Jstun-BindingLifetimeTest", "Timer scheduled: " + binarySearchLifetime + ".");
       
   296  				} else {
       
   297  					completed = true;
       
   298  				}
       
   299  			} catch (SocketTimeoutException ste) {
       
   300 -				LOGGER.debug("Read operation at query socket timeout.");
       
   301 +				Log.d("Jstun-BindingLifetimeTest", "Read operation at query socket timeout.");
       
   302  				if (upperBinarySearchLifetime == (lowerBinarySearchLifetime + 1)) {
       
   303 -					LOGGER.debug("BindingLifetimeTest completed. UDP binding lifetime: " + binarySearchLifetime + ".");
       
   304 +					Log.d("Jstun-BindingLifetimeTest", "BindingLifetimeTest completed. UDP binding lifetime: " + binarySearchLifetime + ".");
       
   305  					completed = true;
       
   306  					return;
       
   307  				}
       
   308 @@ -196,7 +195,7 @@
       
   309  					}
       
   310  					BindingLifetimeTask task = new BindingLifetimeTask();
       
   311  					timer.schedule(task, binarySearchLifetime);
       
   312 -					LOGGER.debug("Timer scheduled: " + binarySearchLifetime + ".");
       
   313 +					Log.d("Jstun-BindingLifetimeTest", "Timer scheduled: " + binarySearchLifetime + ".");
       
   314  				} else {
       
   315  					completed = true;
       
   316  				}
       
   317 diff -Nru src-stun/de/javawi/jstun/test/demo/ice/ICENegociator.java src/de/javawi/jstun/test/demo/ice/ICENegociator.java
       
   318 --- src-stun/de/javawi/jstun/test/demo/ice/ICENegociator.java	2009-03-08 13:40:52.000000000 +0100
       
   319 +++ src/de/javawi/jstun/test/demo/ice/ICENegociator.java	2009-10-03 14:57:51.400971966 +0200
       
   320 @@ -23,9 +23,7 @@
       
   321  import java.util.List;
       
   322  import java.util.Vector;
       
   323  
       
   324 -import org.slf4j.Logger;
       
   325 -import org.slf4j.LoggerFactory;
       
   326 -
       
   327 +import android.util.Log;
       
   328  import de.javawi.jstun.attribute.MessageAttributeException;
       
   329  import de.javawi.jstun.header.MessageHeaderParsingException;
       
   330  import de.javawi.jstun.test.DiscoveryInfo;
       
   331 @@ -35,7 +33,6 @@
       
   332  import de.javawi.jstun.util.UtilityException;
       
   333  
       
   334  public class ICENegociator {
       
   335 -	private static final Logger LOGGER = LoggerFactory.getLogger(ICENegociator.class);
       
   336  	// type preference must be an integer from 0 (=lowest) to 126 (=highest) (inclusive)
       
   337  	private final static int LOCAL_PREFERENCE = 0;
       
   338  	private final static int SERVER_REFLEXIVE_PREFERENCE = 42;
       
   339 @@ -91,29 +88,29 @@
       
   340  								candidates.add(cand);
       
   341  							}
       
   342  						} catch (MessageHeaderParsingException mhpe) {
       
   343 -							LOGGER.debug("MessageHeaderParsingException while gathering candidate addresses.");
       
   344 +							Log.d("Jstun-ICENegociator", "MessageHeaderParsingException while gathering candidate addresses.");
       
   345  							mhpe.printStackTrace();
       
   346  						} catch (MessageAttributeException mae) {
       
   347 -							LOGGER.debug("MessageAttributeException while gathering candidate addresses.");
       
   348 +							Log.d("Jstun-ICENegociator", "MessageAttributeException while gathering candidate addresses.");
       
   349  							mae.printStackTrace();	
       
   350  						} catch (UtilityException ue) {
       
   351 -							LOGGER.debug("UtilityException while gathering candidate addresses.");
       
   352 +							Log.d("Jstun-ICENegociator", "UtilityException while gathering candidate addresses.");
       
   353  							ue.printStackTrace();
       
   354  						} catch (UnknownHostException uhe) {
       
   355 -							LOGGER.debug("MessageHeaderParsingException while gathering candidate addresses.");
       
   356 +							Log.d("Jstun-ICENegociator", "MessageHeaderParsingException while gathering candidate addresses.");
       
   357  							uhe.printStackTrace();
       
   358  						} catch (SocketException se) {
       
   359 -							LOGGER.debug("SocketException while gathering candidate addresses.");
       
   360 +							Log.d("Jstun-ICENegociator", "SocketException while gathering candidate addresses.");
       
   361  							se.printStackTrace();
       
   362  						} catch (IOException ioe) {
       
   363 -							LOGGER.debug("IOException while gathering candidate addresses.");
       
   364 +							Log.d("Jstun-ICENegociator", "IOException while gathering candidate addresses.");
       
   365  							ioe.printStackTrace();
       
   366  						}
       
   367  					}
       
   368  				}
       
   369  			}
       
   370  		} catch (SocketException se) {
       
   371 -			LOGGER.debug("SocketException while enumatering over the network cards.");
       
   372 +			Log.d("Jstun-ICENegociator", "SocketException while enumatering over the network cards.");
       
   373  			se.printStackTrace();
       
   374  		}
       
   375  	}
       
   376 diff -Nru src-stun/de/javawi/jstun/test/demo/StunServer.java src/de/javawi/jstun/test/demo/StunServer.java
       
   377 --- src-stun/de/javawi/jstun/test/demo/StunServer.java	2009-03-08 13:52:00.000000000 +0100
       
   378 +++ src/de/javawi/jstun/test/demo/StunServer.java	2009-10-03 14:57:05.248972557 +0200
       
   379 @@ -23,8 +23,7 @@
       
   380  import java.util.logging.Level;
       
   381  import java.util.logging.SimpleFormatter;
       
   382  
       
   383 -import org.slf4j.Logger;
       
   384 -import org.slf4j.LoggerFactory;
       
   385 +import android.util.Log;
       
   386  
       
   387  import de.javawi.jstun.attribute.ChangeRequest;
       
   388  import de.javawi.jstun.attribute.ChangedAddress;
       
   389 @@ -47,7 +46,6 @@
       
   390   * The server requires a machine that is dual-homed to be functional. 
       
   391   */
       
   392  public class StunServer {
       
   393 -	private static final Logger LOGGER = LoggerFactory.getLogger(StunServer.class);
       
   394  	Vector<DatagramSocket> sockets;
       
   395  	
       
   396  	public StunServer(int primaryPort, InetAddress primary, int secondaryPort, InetAddress secondary) throws SocketException {
       
   397 @@ -99,12 +97,12 @@
       
   398  				try {
       
   399  					DatagramPacket receive = new DatagramPacket(new byte[200], 200);
       
   400  					receiverSocket.receive(receive);
       
   401 -					LOGGER.debug(receiverSocket.getLocalAddress().getHostAddress() + ":" + receiverSocket.getLocalPort() + " datagram received from " + receive.getAddress().getHostAddress() + ":" + receive.getPort());
       
   402 +					Log.d("Jstun-StunServer", receiverSocket.getLocalAddress().getHostAddress() + ":" + receiverSocket.getLocalPort() + " datagram received from " + receive.getAddress().getHostAddress() + ":" + receive.getPort());
       
   403  					MessageHeader receiveMH = MessageHeader.parseHeader(receive.getData()); 
       
   404  					try {
       
   405  						receiveMH.parseAttributes(receive.getData());
       
   406  						if (receiveMH.getType() == MessageHeaderType.BindingRequest) {
       
   407 -							LOGGER.debug(receiverSocket.getLocalAddress().getHostAddress() + ":" + receiverSocket.getLocalPort() + " Binding Request received from " + receive.getAddress().getHostAddress() + ":" + receive.getPort());
       
   408 +							Log.d("Jstun-StunServer", receiverSocket.getLocalAddress().getHostAddress() + ":" + receiverSocket.getLocalPort() + " Binding Request received from " + receive.getAddress().getHostAddress() + ":" + receive.getPort());
       
   409  							ChangeRequest cr = (ChangeRequest) receiveMH.getMessageAttribute(MessageAttributeType.ChangeRequest);
       
   410  							if (cr == null) throw new MessageAttributeException("Message attribute change request is not set.");
       
   411  							ResponseAddress ra = (ResponseAddress) receiveMH.getMessageAttribute(MessageAttributeType.ResponseAddress);
       
   412 @@ -123,7 +121,7 @@
       
   413  							ca.setPort(changedPortIP.getLocalPort());
       
   414  							sendMH.addMessageAttribute(ca);
       
   415  							if (cr.isChangePort() && (!cr.isChangeIP())) {
       
   416 -								LOGGER.debug("Change port received in Change Request attribute");
       
   417 +								Log.d("Jstun-StunServer", "Change port received in Change Request attribute");
       
   418  								// Source address attribute
       
   419  								SourceAddress sa = new SourceAddress();
       
   420  								sa.setAddress(new Address(changedPort.getLocalAddress().getAddress()));
       
   421 @@ -139,9 +137,9 @@
       
   422  									send.setAddress(receive.getAddress());
       
   423  								}
       
   424  								changedPort.send(send);
       
   425 -								LOGGER.debug(changedPort.getLocalAddress().getHostAddress() + ":" + changedPort.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   426 +								Log.d("Jstun-StunServer", changedPort.getLocalAddress().getHostAddress() + ":" + changedPort.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   427  							} else if ((!cr.isChangePort()) && cr.isChangeIP()) {
       
   428 -								LOGGER.debug("Change ip received in Change Request attribute");
       
   429 +								Log.d("Jstun-StunServer", "Change ip received in Change Request attribute");
       
   430  								// Source address attribute
       
   431  								SourceAddress sa = new SourceAddress();
       
   432  								sa.setAddress(new Address(changedIP.getLocalAddress().getAddress()));
       
   433 @@ -157,9 +155,9 @@
       
   434  									send.setAddress(receive.getAddress());
       
   435  								}
       
   436  								changedIP.send(send);
       
   437 -								LOGGER.debug(changedIP.getLocalAddress().getHostAddress() + ":" + changedIP.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   438 +								Log.d("Jstun-StunServer", changedIP.getLocalAddress().getHostAddress() + ":" + changedIP.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   439  							} else if ((!cr.isChangePort()) && (!cr.isChangeIP())) {
       
   440 -								LOGGER.debug("Nothing received in Change Request attribute");
       
   441 +								Log.d("Jstun-StunServer", "Nothing received in Change Request attribute");
       
   442  								// Source address attribute
       
   443  								SourceAddress sa = new SourceAddress();
       
   444  								sa.setAddress(new Address(receiverSocket.getLocalAddress().getAddress()));
       
   445 @@ -175,9 +173,9 @@
       
   446  									send.setAddress(receive.getAddress());
       
   447  								}
       
   448  								receiverSocket.send(send);
       
   449 -								LOGGER.debug(receiverSocket.getLocalAddress().getHostAddress() + ":" + receiverSocket.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   450 +								Log.d("Jstun-StunServer", receiverSocket.getLocalAddress().getHostAddress() + ":" + receiverSocket.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   451  							} else if (cr.isChangePort() && cr.isChangeIP()) {
       
   452 -								LOGGER.debug("Change port and ip received in Change Request attribute");
       
   453 +								Log.d("Jstun-StunServer", "Change port and ip received in Change Request attribute");
       
   454  								// Source address attribute
       
   455  								SourceAddress sa = new SourceAddress();
       
   456  								sa.setAddress(new Address(changedPortIP.getLocalAddress().getAddress()));
       
   457 @@ -193,7 +191,7 @@
       
   458  									send.setAddress(receive.getAddress());
       
   459  								}
       
   460  								changedPortIP.send(send);
       
   461 -								LOGGER.debug(changedPortIP.getLocalAddress().getHostAddress() + ":" + changedPortIP.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   462 +								Log.d("Jstun-StunServer", changedPortIP.getLocalAddress().getHostAddress() + ":" + changedPortIP.getLocalPort() + " send Binding Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   463  							}
       
   464  						}
       
   465  					} catch (UnknownMessageAttributeException umae) {
       
   466 @@ -212,7 +210,7 @@
       
   467  						send.setPort(receive.getPort());
       
   468  						send.setAddress(receive.getAddress());
       
   469  						receiverSocket.send(send);
       
   470 -						LOGGER.debug(changedPortIP.getLocalAddress().getHostAddress() + ":" + changedPortIP.getLocalPort() + " send Binding Error Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   471 +						Log.d("Jstun-StunServer", changedPortIP.getLocalAddress().getHostAddress() + ":" + changedPortIP.getLocalPort() + " send Binding Error Response to " + send.getAddress().getHostAddress() + ":" + send.getPort());
       
   472  					}	
       
   473  				} catch (IOException ioe) {
       
   474  					ioe.printStackTrace();
       
   475 diff -Nru src-stun/de/javawi/jstun/test/DiscoveryTest.java src/de/javawi/jstun/test/DiscoveryTest.java
       
   476 --- src-stun/de/javawi/jstun/test/DiscoveryTest.java	2009-03-08 13:45:49.000000000 +0100
       
   477 +++ src/de/javawi/jstun/test/DiscoveryTest.java	2009-10-03 14:56:26.816979238 +0200
       
   478 @@ -20,8 +20,7 @@
       
   479  import java.net.SocketTimeoutException;
       
   480  import java.net.UnknownHostException;
       
   481  
       
   482 -import org.slf4j.Logger;
       
   483 -import org.slf4j.LoggerFactory;
       
   484 +import android.util.Log;
       
   485  
       
   486  import de.javawi.jstun.attribute.ChangeRequest;
       
   487  import de.javawi.jstun.attribute.ChangedAddress;
       
   488 @@ -35,7 +34,6 @@
       
   489  import de.javawi.jstun.util.UtilityException;
       
   490  
       
   491  public class DiscoveryTest {
       
   492 -	private static final Logger LOGGER = LoggerFactory.getLogger(DiscoveryTest.class);
       
   493  	InetAddress iaddress;
       
   494  	String stunServer;
       
   495  	int port;
       
   496 @@ -93,7 +91,7 @@
       
   497  				byte[] data = sendMH.getBytes();
       
   498  				DatagramPacket send = new DatagramPacket(data, data.length);
       
   499  				socketTest1.send(send);
       
   500 -				LOGGER.debug("Test 1: Binding Request sent.");
       
   501 +				Log.d("Jstun-DiscoveryTest", "Test 1: Binding Request sent.");
       
   502  			
       
   503  				MessageHeader receiveMH = new MessageHeader();
       
   504  				while (!(receiveMH.equalTransactionID(sendMH))) {
       
   505 @@ -108,35 +106,35 @@
       
   506  				ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode);
       
   507  				if (ec != null) {
       
   508  					di.setError(ec.getResponseCode(), ec.getReason());
       
   509 -					LOGGER.debug("Message header contains an Errorcode message attribute.");
       
   510 +					Log.d("Jstun-DiscoveryTest", "Message header contains an Errorcode message attribute.");
       
   511  					return false;
       
   512  				}
       
   513  				if ((ma == null) || (ca == null)) {
       
   514  					di.setError(700, "The server is sending an incomplete response (Mapped Address and Changed Address message attributes are missing). The client should not retry.");
       
   515 -					LOGGER.debug("Response does not contain a Mapped Address or Changed Address message attribute.");
       
   516 +					Log.d("Jstun-DiscoveryTest", "Response does not contain a Mapped Address or Changed Address message attribute.");
       
   517  					return false;
       
   518  				} else {
       
   519  					di.setPublicIP(ma.getAddress().getInetAddress());
       
   520  					if ((ma.getPort() == socketTest1.getLocalPort()) && (ma.getAddress().getInetAddress().equals(socketTest1.getLocalAddress()))) {
       
   521 -						LOGGER.debug("Node is not natted.");
       
   522 +						Log.d("Jstun-DiscoveryTest", "Node is not natted.");
       
   523  						nodeNatted = false;
       
   524  					} else {
       
   525 -						LOGGER.debug("Node is natted.");
       
   526 +						Log.d("Jstun-DiscoveryTest", "Node is natted.");
       
   527  					}
       
   528  					return true;
       
   529  				}
       
   530  			} catch (SocketTimeoutException ste) {
       
   531  				if (timeSinceFirstTransmission < 7900) {
       
   532 -					LOGGER.debug("Test 1: Socket timeout while receiving the response.");
       
   533 +					Log.d("Jstun-DiscoveryTest", "Test 1: Socket timeout while receiving the response.");
       
   534  					timeSinceFirstTransmission += timeout;
       
   535  					int timeoutAddValue = (timeSinceFirstTransmission * 2);
       
   536  					if (timeoutAddValue > 1600) timeoutAddValue = 1600;
       
   537  					timeout = timeoutAddValue;
       
   538  				} else {
       
   539  					// node is not capable of udp communication
       
   540 -					LOGGER.debug("Test 1: Socket timeout while receiving the response. Maximum retry limit exceed. Give up.");
       
   541 +					Log.d("Jstun-DiscoveryTest", "Test 1: Socket timeout while receiving the response. Maximum retry limit exceed. Give up.");
       
   542  					di.setBlockedUDP();
       
   543 -					LOGGER.debug("Node is not capable of UDP communication.");
       
   544 +					Log.d("Jstun-DiscoveryTest", "Node is not capable of UDP communication.");
       
   545  					return false;
       
   546  				}
       
   547  			} 
       
   548 @@ -164,7 +162,7 @@
       
   549  				byte[] data = sendMH.getBytes(); 
       
   550  				DatagramPacket send = new DatagramPacket(data, data.length);
       
   551  				sendSocket.send(send);
       
   552 -				LOGGER.debug("Test 2: Binding Request sent.");
       
   553 +				Log.d("Jstun-DiscoveryTest", "Test 2: Binding Request sent.");
       
   554  				
       
   555  				int localPort = sendSocket.getLocalPort();
       
   556  				InetAddress localAddress = sendSocket.getLocalAddress();
       
   557 @@ -185,29 +183,29 @@
       
   558  				ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode);
       
   559  				if (ec != null) {
       
   560  					di.setError(ec.getResponseCode(), ec.getReason());
       
   561 -					LOGGER.debug("Message header contains an Errorcode message attribute.");
       
   562 +					Log.d("Jstun-DiscoveryTest", "Message header contains an Errorcode message attribute.");
       
   563  					return false;
       
   564  				}
       
   565  				if (!nodeNatted) {
       
   566  					di.setOpenAccess();
       
   567 -					LOGGER.debug("Node has open access to the Internet (or, at least the node is behind a full-cone NAT without translation).");
       
   568 +					Log.d("Jstun-DiscoveryTest", "Node has open access to the Internet (or, at least the node is behind a full-cone NAT without translation).");
       
   569  				} else {
       
   570  					di.setFullCone();
       
   571 -					LOGGER.debug("Node is behind a full-cone NAT.");
       
   572 +					Log.d("Jstun-DiscoveryTest", "Node is behind a full-cone NAT.");
       
   573  				}
       
   574  				return false;
       
   575  			} catch (SocketTimeoutException ste) {
       
   576  				if (timeSinceFirstTransmission < 7900) {
       
   577 -					LOGGER.debug("Test 2: Socket timeout while receiving the response.");
       
   578 +					Log.d("Jstun-DiscoveryTest", "Test 2: Socket timeout while receiving the response.");
       
   579  					timeSinceFirstTransmission += timeout;
       
   580  					int timeoutAddValue = (timeSinceFirstTransmission * 2);
       
   581  					if (timeoutAddValue > 1600) timeoutAddValue = 1600;
       
   582  					timeout = timeoutAddValue;
       
   583  				} else {
       
   584 -					LOGGER.debug("Test 2: Socket timeout while receiving the response. Maximum retry limit exceed. Give up.");
       
   585 +					Log.d("Jstun-DiscoveryTest", "Test 2: Socket timeout while receiving the response. Maximum retry limit exceed. Give up.");
       
   586  					if (!nodeNatted) {
       
   587  						di.setSymmetricUDPFirewall();
       
   588 -						LOGGER.debug("Node is behind a symmetric UDP firewall.");
       
   589 +						Log.d("Jstun-DiscoveryTest", "Node is behind a symmetric UDP firewall.");
       
   590  						return false;
       
   591  					} else {
       
   592  						// not is natted
       
   593 @@ -238,7 +236,7 @@
       
   594  				byte[] data = sendMH.getBytes();
       
   595  				DatagramPacket send = new DatagramPacket(data, data.length);
       
   596  				socketTest1.send(send);
       
   597 -				LOGGER.debug("Test 1 redo with changed address: Binding Request sent.");
       
   598 +				Log.d("Jstun-DiscoveryTest", "Test 1 redo with changed address: Binding Request sent.");
       
   599  				
       
   600  				MessageHeader receiveMH = new MessageHeader();
       
   601  				while (!(receiveMH.equalTransactionID(sendMH))) {
       
   602 @@ -251,30 +249,30 @@
       
   603  				ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode);
       
   604  				if (ec != null) {
       
   605  					di.setError(ec.getResponseCode(), ec.getReason());
       
   606 -					LOGGER.debug("Message header contains an Errorcode message attribute.");
       
   607 +					Log.d("Jstun-DiscoveryTest", "Message header contains an Errorcode message attribute.");
       
   608  					return false;
       
   609  				}
       
   610  				if (ma2 == null) {
       
   611  					di.setError(700, "The server is sending an incomplete response (Mapped Address message attribute is missing). The client should not retry.");
       
   612 -					LOGGER.debug("Response does not contain a Mapped Address message attribute.");
       
   613 +					Log.d("Jstun-DiscoveryTest", "Response does not contain a Mapped Address message attribute.");
       
   614  					return false;
       
   615  				} else {
       
   616  					if ((ma.getPort() != ma2.getPort()) || (!(ma.getAddress().getInetAddress().equals(ma2.getAddress().getInetAddress())))) {
       
   617  						di.setSymmetric();
       
   618 -						LOGGER.debug("Node is behind a symmetric NAT.");
       
   619 +						Log.d("Jstun-DiscoveryTest", "Node is behind a symmetric NAT.");
       
   620  						return false;
       
   621  					}
       
   622  				}
       
   623  				return true;
       
   624  			} catch (SocketTimeoutException ste2) {
       
   625  				if (timeSinceFirstTransmission < 7900) {
       
   626 -					LOGGER.debug("Test 1 redo with changed address: Socket timeout while receiving the response.");
       
   627 +					Log.d("Jstun-DiscoveryTest", "Test 1 redo with changed address: Socket timeout while receiving the response.");
       
   628  					timeSinceFirstTransmission += timeout;
       
   629  					int timeoutAddValue = (timeSinceFirstTransmission * 2);
       
   630  					if (timeoutAddValue > 1600) timeoutAddValue = 1600;
       
   631  					timeout = timeoutAddValue;
       
   632  				} else {
       
   633 -					LOGGER.debug("Test 1 redo with changed address: Socket timeout while receiving the response.  Maximum retry limit exceed. Give up.");
       
   634 +					Log.d("Jstun-DiscoveryTest", "Test 1 redo with changed address: Socket timeout while receiving the response.  Maximum retry limit exceed. Give up.");
       
   635  					return false;
       
   636  				}
       
   637  			}
       
   638 @@ -301,7 +299,7 @@
       
   639  				byte[] data = sendMH.getBytes();
       
   640  				DatagramPacket send = new DatagramPacket(data, data.length);
       
   641  				sendSocket.send(send);
       
   642 -				LOGGER.debug("Test 3: Binding Request sent.");
       
   643 +				Log.d("Jstun-DiscoveryTest", "Test 3: Binding Request sent.");
       
   644  				
       
   645  				int localPort = sendSocket.getLocalPort();
       
   646  				InetAddress localAddress = sendSocket.getLocalAddress();
       
   647 @@ -322,25 +320,25 @@
       
   648  				ErrorCode ec = (ErrorCode) receiveMH.getMessageAttribute(MessageAttribute.MessageAttributeType.ErrorCode);
       
   649  				if (ec != null) {
       
   650  					di.setError(ec.getResponseCode(), ec.getReason());
       
   651 -					LOGGER.debug("Message header contains an Errorcode message attribute.");
       
   652 +					Log.d("Jstun-DiscoveryTest", "Message header contains an Errorcode message attribute.");
       
   653  					return;
       
   654  				}
       
   655  				if (nodeNatted) {
       
   656  					di.setRestrictedCone();
       
   657 -					LOGGER.debug("Node is behind a restricted NAT.");
       
   658 +					Log.d("Jstun-DiscoveryTest", "Node is behind a restricted NAT.");
       
   659  					return;
       
   660  				}
       
   661  			} catch (SocketTimeoutException ste) {
       
   662  				if (timeSinceFirstTransmission < 7900) {
       
   663 -					LOGGER.debug("Test 3: Socket timeout while receiving the response.");
       
   664 +					Log.d("Jstun-DiscoveryTest", "Test 3: Socket timeout while receiving the response.");
       
   665  					timeSinceFirstTransmission += timeout;
       
   666  					int timeoutAddValue = (timeSinceFirstTransmission * 2);
       
   667  					if (timeoutAddValue > 1600) timeoutAddValue = 1600;
       
   668  					timeout = timeoutAddValue;
       
   669  				} else {
       
   670 -					LOGGER.debug("Test 3: Socket timeout while receiving the response. Maximum retry limit exceed. Give up.");
       
   671 +					Log.d("Jstun-DiscoveryTest", "Test 3: Socket timeout while receiving the response. Maximum retry limit exceed. Give up.");
       
   672  					di.setPortRestrictedCone();
       
   673 -					LOGGER.debug("Node is behind a port restricted NAT.");
       
   674 +					Log.d("Jstun-DiscoveryTest", "Node is behind a port restricted NAT.");
       
   675  					return;
       
   676  				}
       
   677  			}