linphone-iphone/p2pproxy/dependencies-src/jstun-src-0.7.1/de/javawi/jstun/attribute/Dummy.java
aymeric 2b8200409c Initial import
git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@1 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
2008-09-04 15:47:34 +00:00

42 lines
1.1 KiB
Java

/*
* This file is part of JSTUN.
*
* Copyright (c) 2005 Thomas King <king@t-king.de> - All rights
* reserved.
*
* This software is licensed under either the GNU Public License (GPL),
* or the Apache 2.0 license. Copies of both license agreements are
* included in this distribution.
*/
package de.javawi.jstun.attribute;
import de.javawi.jstun.util.Utility;
import de.javawi.jstun.util.UtilityException;
public class Dummy extends MessageAttribute {
int lengthValue;
public Dummy() {
super(MessageAttributeType.Dummy);
}
public void setLengthValue(int length) {
this.lengthValue = length;
}
public byte[] getBytes() throws UtilityException {
byte[] result = new byte[lengthValue + 4];
// message attribute header
// type
System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2);
// length
System.arraycopy(Utility.integerToTwoBytes(lengthValue), 0, result, 2, 2);
return result;
}
public static Dummy parse(byte[] data) {
Dummy dummy = new Dummy();
dummy.setLengthValue(data.length);
return dummy;
}
}