public void generateTransactionID() throws UtilityException { System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 0, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 2, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 4, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 6, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 8, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 10, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 12, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 14, 2); }
public void generateTransactionID() throws UtilityException { System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 0, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 2, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 4, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 6, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 8, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 10, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 12, 2); System.arraycopy(Utility.integerToTwoBytes((int)(Math.random() * 65536)), 0, id, 14, 2); }
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 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 byte[] getBytes() throws UtilityException { int length = username.length(); // username header if ((length % 4) != 0) { length += 4 - (length % 4); } // message attribute header length += 4; byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length-4), 0, result, 2, 2); // username header byte[] temp = username.getBytes(); System.arraycopy(temp, 0, result, 4, temp.length); return result; }
public byte[] getBytes() throws UtilityException { byte[] result = new byte[12]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(8), 0, result, 2, 2); // mappedaddress header // family result[5] = Utility.integerToOneByte(0x01); // port System.arraycopy(Utility.integerToTwoBytes(port), 0, result, 6, 2); // address System.arraycopy(address.getBytes(), 0, result, 8, 4); return result; }
public byte[] getBytes() throws UtilityException { int length = password.length(); // password header if ((length % 4) != 0) { length += 4 - (length % 4); } // message attribute header length += 4; byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length - 4), 0, result, 2, 2); // password header byte[] temp = password.getBytes(); System.arraycopy(temp, 0, result, 4, temp.length); return result; }
public byte[] getBytes() throws UtilityException { int length = username.length(); // username header if ((length % 4) != 0) { length += 4 - (length % 4); } // message attribute header length += 4; byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length-4), 0, result, 2, 2); // username header byte[] temp = username.getBytes(); System.arraycopy(temp, 0, result, 4, temp.length); return result; }
public byte[] getBytes() throws UtilityException { int length = password.length(); // password header if ((length % 4) != 0) { length += 4 - (length % 4); } // message attribute header length += 4; byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length - 4), 0, result, 2, 2); // password header byte[] temp = password.getBytes(); System.arraycopy(temp, 0, result, 4, temp.length); return result; }
public byte[] getBytes() throws UtilityException { byte[] result = new byte[12]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(8), 0, result, 2, 2); // mappedaddress header // family result[5] = Utility.integerToOneByte(0x01); // port System.arraycopy(Utility.integerToTwoBytes(port), 0, result, 6, 2); // address System.arraycopy(address.getBytes(), 0, result, 8, 4); return result; }
public byte[] getBytes() throws UtilityException { int length = 0; if (unkown.size()%2 == 1) { length = 2 * (unkown.size() + 1) + 4; } else { length = 2 * unkown.size() + 4; } byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length - 4), 0, result, 2, 2); // unkown attribute header Iterator<MessageAttributeType> it = unkown.iterator(); while(it.hasNext()) { MessageAttributeType attri = it.next(); System.arraycopy(Utility.integerToTwoBytes(typeToInteger(attri)), 0, result, 4, 2); } // padding if (unkown.size()%2 == 1) { System.arraycopy(Utility.integerToTwoBytes(typeToInteger(unkown.elementAt(1))), 0, result, 4, 2); } return result; }
public byte[] getBytes() throws UtilityException { int length = 0; if (unkown.size()%2 == 1) { length = 2 * (unkown.size() + 1) + 4; } else { length = 2 * unkown.size() + 4; } byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length - 4), 0, result, 2, 2); // unkown attribute header Iterator<MessageAttributeType> it = unkown.iterator(); while(it.hasNext()) { MessageAttributeType attri = it.next(); System.arraycopy(Utility.integerToTwoBytes(typeToInteger(attri)), 0, result, 4, 2); } // padding if (unkown.size()%2 == 1) { System.arraycopy(Utility.integerToTwoBytes(typeToInteger(unkown.elementAt(1))), 0, result, 4, 2); } return result; }
public byte[] getBytes() throws UtilityException { byte[] result = new byte[8]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(4), 0, result, 2, 2); // change request header if (changeIP) result[7] = Utility.integerToOneByte(4); if (changePort) result[7] = Utility.integerToOneByte(2); if (changeIP && changePort) result[7] = Utility.integerToOneByte(6); return result; }
public byte[] getBytes() throws UtilityException { int length = reason.length(); // length adjustment if ((length % 4) != 0) { length += 4 - (length % 4); } // message attribute header length += 4; byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length-4), 0, result, 2, 2); // error code header int classHeader = (int) Math.floor(((double)responseCode)/100); result[6] = Utility.integerToOneByte(classHeader); result[7] = Utility.integerToOneByte(responseCode%100); byte[] reasonArray = reason.getBytes(); System.arraycopy(reasonArray, 0, result, 8, reasonArray.length); return result; }
public byte[] getBytes() throws UtilityException { byte[] result = new byte[8]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(4), 0, result, 2, 2); // change request header if (changeIP) result[7] = Utility.integerToOneByte(4); if (changePort) result[7] = Utility.integerToOneByte(2); if (changeIP && changePort) result[7] = Utility.integerToOneByte(6); return result; }
public byte[] getBytes() throws UtilityException { int length = reason.length(); // length adjustment if ((length % 4) != 0) { length += 4 - (length % 4); } // message attribute header length += 4; byte[] result = new byte[length]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(length-4), 0, result, 2, 2); // error code header int classHeader = (int) Math.floor(((double)responseCode)/100); result[6] = Utility.integerToOneByte(classHeader); result[7] = Utility.integerToOneByte(responseCode%100); byte[] reasonArray = reason.getBytes(); System.arraycopy(reasonArray, 0, result, 8, reasonArray.length); return result; }
public byte[] getBytes() throws UtilityException { int length = 20; Iterator<MessageAttribute.MessageAttributeType> it = ma.keySet().iterator(); while (it.hasNext()) { MessageAttribute attri = ma.get(it.next()); length += attri.getLength(); } // add attribute size + attributes.getSize(); byte[] result = new byte[length]; System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); System.arraycopy(Utility.integerToTwoBytes(length-20), 0, result, 2, 2); System.arraycopy(id, 0, result, 4, 16); // arraycopy of attributes int offset = 20; it = ma.keySet().iterator(); while (it.hasNext()) { MessageAttribute attri = ma.get(it.next()); System.arraycopy(attri.getBytes(), 0, result, offset, attri.getLength()); offset += attri.getLength(); } return result; }
public byte[] getBytes() throws UtilityException { int length = 20; Iterator<MessageAttribute.MessageAttributeType> it = ma.keySet().iterator(); while (it.hasNext()) { MessageAttribute attri = ma.get(it.next()); length += attri.getLength(); } // add attribute size + attributes.getSize(); byte[] result = new byte[length]; System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); System.arraycopy(Utility.integerToTwoBytes(length-20), 0, result, 2, 2); System.arraycopy(id, 0, result, 4, 16); // arraycopy of attributes int offset = 20; it = ma.keySet().iterator(); while (it.hasNext()) { MessageAttribute attri = ma.get(it.next()); System.arraycopy(attri.getBytes(), 0, result, offset, attri.getLength()); offset += attri.getLength(); } return result; }