diff --git a/router/java/src/net/i2p/data/i2np/DatabaseSearchReplyMessage.java b/router/java/src/net/i2p/data/i2np/DatabaseSearchReplyMessage.java index 1df280349ef78e11a141b438257f815ef1e02ab1..5ea08428a9da64a3efd66b2bfa964f94dfd31968 100644 --- a/router/java/src/net/i2p/data/i2np/DatabaseSearchReplyMessage.java +++ b/router/java/src/net/i2p/data/i2np/DatabaseSearchReplyMessage.java @@ -103,8 +103,7 @@ public class DatabaseSearchReplyMessage extends FastI2NPMessageImpl { System.arraycopy(_key.getData(), 0, out, curIndex, Hash.HASH_LENGTH); curIndex += Hash.HASH_LENGTH; - DataHelper.toLong(out, curIndex, 1, _peerHashes.size()); - curIndex++; + out[curIndex++] = (byte) _peerHashes.size(); for (int i = 0; i < getNumReplies(); i++) { System.arraycopy(getReply(i).getData(), 0, out, curIndex, Hash.HASH_LENGTH); curIndex += Hash.HASH_LENGTH; diff --git a/router/java/src/net/i2p/data/i2np/DeliveryInstructions.java b/router/java/src/net/i2p/data/i2np/DeliveryInstructions.java index 703f43ef296b29363dea8501dd7be1e2eebbd800..83a1ac39b2e7b5415b25477b758986227d5f17f7 100644 --- a/router/java/src/net/i2p/data/i2np/DeliveryInstructions.java +++ b/router/java/src/net/i2p/data/i2np/DeliveryInstructions.java @@ -411,8 +411,7 @@ public class DeliveryInstructions extends DataStructureImpl { // _log.debug("Write flags: " + flags + " mode: " + getDeliveryMode() // + " =?= " + flagMode(flags)); int origOffset = offset; - DataHelper.toLong(target, offset, 1, flags); - offset++; + target[offset++] = (byte) flags; offset += getAdditionalInfo(target, offset); return offset - origOffset; } diff --git a/router/java/src/net/i2p/data/i2np/FastI2NPMessageImpl.java b/router/java/src/net/i2p/data/i2np/FastI2NPMessageImpl.java index 63e64fa65c2e1faadb9d54809648e6c5a4e7aef4..bbf6f78fa16aff1c69cfe273c917ea783af536a1 100644 --- a/router/java/src/net/i2p/data/i2np/FastI2NPMessageImpl.java +++ b/router/java/src/net/i2p/data/i2np/FastI2NPMessageImpl.java @@ -150,8 +150,7 @@ public abstract class FastI2NPMessageImpl extends I2NPMessageImpl { } int payloadLen = writtenLen - HEADER_LENGTH; int off = 0; - DataHelper.toLong(buffer, off, 1, getType()); - off += 1; + buffer[off++] = (byte) getType(); DataHelper.toLong(buffer, off, 4, _uniqueId); off += 4; DataHelper.toLong(buffer, off, DataHelper.DATE_LENGTH, _expiration); diff --git a/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java b/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java index ba20bf27158d7e2243143fcc14bc234aa58db290..fa6fe8784c5088541602382f1daf821b19198277 100644 --- a/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java +++ b/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java @@ -257,8 +257,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM byte[] h = SimpleByteCache.acquire(Hash.HASH_LENGTH); _context.sha().calculateHash(buffer, off + HEADER_LENGTH, payloadLen, h, 0); - DataHelper.toLong(buffer, off, 1, getType()); - off++; + buffer[off++] = (byte) getType(); // Lazy initialization of value if (_uniqueId < 0) { @@ -300,8 +299,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM public int toRawByteArray(byte buffer[]) { try { int off = 0; - DataHelper.toLong(buffer, off, 1, getType()); - off += 1; + buffer[off++] = (byte) getType(); // January 19 2038? No, unsigned, good until Feb. 7 2106 // in seconds, round up so we don't lose time every hop DataHelper.toLong(buffer, off, 4, (_expiration + 500) / 1000); @@ -325,8 +323,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM */ public int toRawByteArrayNTCP2(byte buffer[], int off) { try { - DataHelper.toLong(buffer, off, 1, getType()); - off += 1; + buffer[off++] = (byte) getType(); // Lazy initialization of value if (_uniqueId < 0) { _uniqueId = _context.random().nextLong(MAX_ID_VALUE); diff --git a/router/java/src/net/i2p/data/i2np/VariableTunnelBuildMessage.java b/router/java/src/net/i2p/data/i2np/VariableTunnelBuildMessage.java index 52aa565de7262ad973a84e44b24def0c247aac34..3682a986e37dea18fa7419bd81d8ef927900d4c1 100644 --- a/router/java/src/net/i2p/data/i2np/VariableTunnelBuildMessage.java +++ b/router/java/src/net/i2p/data/i2np/VariableTunnelBuildMessage.java @@ -1,7 +1,6 @@ package net.i2p.data.i2np; import net.i2p.I2PAppContext; -import net.i2p.data.DataHelper; /** * Variable number of records. @@ -46,7 +45,7 @@ public class VariableTunnelBuildMessage extends TunnelBuildMessage { throw new I2NPMessageException("Not large enough (too short by " + remaining + ")"); if (RECORD_COUNT <= 0 || RECORD_COUNT > MAX_RECORD_COUNT) throw new I2NPMessageException("Bad record count " + RECORD_COUNT); - DataHelper.toLong(out, curIndex++, 1, RECORD_COUNT); + out[curIndex++] = (byte) RECORD_COUNT; // can't call super, written length check will fail //return super.writeMessageBody(out, curIndex + 1); for (int i = 0; i < RECORD_COUNT; i++) { diff --git a/router/java/src/net/i2p/data/i2np/VariableTunnelBuildReplyMessage.java b/router/java/src/net/i2p/data/i2np/VariableTunnelBuildReplyMessage.java index 575f5563002a1a424713537d96a27549e5382a62..32b4385531aa12604e76a1574dcd81adc5892646 100644 --- a/router/java/src/net/i2p/data/i2np/VariableTunnelBuildReplyMessage.java +++ b/router/java/src/net/i2p/data/i2np/VariableTunnelBuildReplyMessage.java @@ -48,7 +48,7 @@ public class VariableTunnelBuildReplyMessage extends TunnelBuildReplyMessage { throw new I2NPMessageException("Not large enough (too short by " + remaining + ")"); if (RECORD_COUNT <= 0 || RECORD_COUNT > MAX_RECORD_COUNT) throw new I2NPMessageException("Bad record count " + RECORD_COUNT); - DataHelper.toLong(out, curIndex++, 1, RECORD_COUNT); + out[curIndex++] = (byte) RECORD_COUNT; // can't call super, written length check will fail //return super.writeMessageBody(out, curIndex + 1); for (int i = 0; i < RECORD_COUNT; i++) {