From 7bf57870d6ed41409c7cc1cbfc4b927d49960338 Mon Sep 17 00:00:00 2001 From: dev Date: Sun, 9 Nov 2008 09:49:54 +0000 Subject: [PATCH] and again some more ;) --- core/java/src/net/i2p/data/i2cp/AbuseReason.java | 4 +++- core/java/src/net/i2p/data/i2cp/AbuseSeverity.java | 2 ++ core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java | 2 ++ core/java/src/net/i2p/data/i2cp/DisconnectMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/GetDateMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java | 5 +++++ core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java | 1 + core/java/src/net/i2p/data/i2cp/MessageId.java | 2 ++ core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java | 3 +++ .../src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java | 4 +++- .../java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/SendMessageMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/SessionConfig.java | 2 ++ core/java/src/net/i2p/data/i2cp/SessionId.java | 2 ++ core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java | 3 +++ core/java/src/net/i2p/data/i2cp/SetDateMessage.java | 3 +++ 21 files changed, 58 insertions(+), 2 deletions(-) diff --git a/core/java/src/net/i2p/data/i2cp/AbuseReason.java b/core/java/src/net/i2p/data/i2cp/AbuseReason.java index d1d87a3a9..3e2632736 100644 --- a/core/java/src/net/i2p/data/i2cp/AbuseReason.java +++ b/core/java/src/net/i2p/data/i2cp/AbuseReason.java @@ -39,11 +39,13 @@ public class AbuseReason extends DataStructureImpl { public void setReason(String reason) { _reason = reason; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _reason = DataHelper.readString(in); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_reason == null) throw new DataFormatException("Invalid abuse reason"); DataHelper.writeString(out, _reason); diff --git a/core/java/src/net/i2p/data/i2cp/AbuseSeverity.java b/core/java/src/net/i2p/data/i2cp/AbuseSeverity.java index 2f9140e08..6e392a2bd 100644 --- a/core/java/src/net/i2p/data/i2cp/AbuseSeverity.java +++ b/core/java/src/net/i2p/data/i2cp/AbuseSeverity.java @@ -41,10 +41,12 @@ public class AbuseSeverity extends DataStructureImpl { _severityId = id; } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _severityId = (int) DataHelper.readLong(in, 1); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_severityId < 0) throw new DataFormatException("Invalid abuse severity: " + _severityId); DataHelper.writeLong(out, 1, _severityId); diff --git a/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java b/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java index 2d1643c97..e6bdfaff8 100644 --- a/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java +++ b/core/java/src/net/i2p/data/i2cp/CreateLeaseSetMessage.java @@ -73,6 +73,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl { _leaseSet = leaseSet; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); @@ -88,6 +89,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if ((_sessionId == null) || (_signingPrivateKey == null) || (_privateKey == null) || (_leaseSet == null)) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); @@ -107,6 +109,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl { return os.toByteArray(); } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java b/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java index e86261438..04b5f5840 100644 --- a/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java +++ b/core/java/src/net/i2p/data/i2cp/CreateSessionMessage.java @@ -44,6 +44,7 @@ public class CreateSessionMessage extends I2CPMessageImpl { _sessionConfig = config; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { SessionConfig config = new SessionConfig(); try { @@ -54,6 +55,7 @@ public class CreateSessionMessage extends I2CPMessageImpl { setSessionConfig(config); } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionConfig == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); @@ -66,6 +68,7 @@ public class CreateSessionMessage extends I2CPMessageImpl { return os.toByteArray(); } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java b/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java index 8fc0e2dbc..a6f43dc7b 100644 --- a/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java +++ b/core/java/src/net/i2p/data/i2cp/DestroySessionMessage.java @@ -40,6 +40,7 @@ public class DestroySessionMessage extends I2CPMessageImpl { _sessionId = id; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { SessionId id = new SessionId(); try { @@ -50,6 +51,7 @@ public class DestroySessionMessage extends I2CPMessageImpl { setSessionId(id); } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionId == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); diff --git a/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java b/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java index 143a76203..07e61384a 100644 --- a/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java +++ b/core/java/src/net/i2p/data/i2cp/DisconnectMessage.java @@ -40,6 +40,7 @@ public class DisconnectMessage extends I2CPMessageImpl { _reason = reason; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _reason = DataHelper.readString(in); @@ -48,6 +49,7 @@ public class DisconnectMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { @@ -58,6 +60,7 @@ public class DisconnectMessage extends I2CPMessageImpl { return os.toByteArray(); } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/GetDateMessage.java b/core/java/src/net/i2p/data/i2cp/GetDateMessage.java index 8e90cef67..92c602628 100644 --- a/core/java/src/net/i2p/data/i2cp/GetDateMessage.java +++ b/core/java/src/net/i2p/data/i2cp/GetDateMessage.java @@ -26,15 +26,18 @@ public class GetDateMessage extends I2CPMessageImpl { super(); } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { // noop } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { byte rv[] = new byte[0]; return rv; } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java b/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java index af86863d2..cb0ee9dda 100644 --- a/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java +++ b/core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java @@ -34,6 +34,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM * * @throws IOException */ + @Override public void readMessage(InputStream in) throws I2CPMessageException, IOException { int length = 0; try { @@ -57,6 +58,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM * @param length number of bytes in the message payload * @throws IOException */ + @Override public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException { if (type != getType()) throw new I2CPMessageException("Invalid message type (found: " + type + " supported: " + getType() @@ -103,6 +105,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM * * @throws IOException */ + @Override public void writeMessage(OutputStream out) throws I2CPMessageException, IOException { byte[] data = doWriteMessage(); try { @@ -114,6 +117,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM out.write(data); } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { try { readMessage(in); @@ -122,6 +126,7 @@ public abstract class I2CPMessageImpl extends DataStructureImpl implements I2CPM } } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { try { writeMessage(out); diff --git a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java index 53650ec19..2414b0da9 100644 --- a/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java +++ b/core/java/src/net/i2p/data/i2cp/I2CPMessageReader.java @@ -144,6 +144,7 @@ public class I2CPMessageReader { _stream = null; } + @Override public void run() { while (_stayAlive) { while (_doRun) { diff --git a/core/java/src/net/i2p/data/i2cp/MessageId.java b/core/java/src/net/i2p/data/i2cp/MessageId.java index d31d478f1..76da41cdb 100644 --- a/core/java/src/net/i2p/data/i2cp/MessageId.java +++ b/core/java/src/net/i2p/data/i2cp/MessageId.java @@ -43,10 +43,12 @@ public class MessageId extends DataStructureImpl { _messageId = id; } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _messageId = DataHelper.readLong(in, 4); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_messageId < 0) throw new DataFormatException("Invalid message ID: " + _messageId); DataHelper.writeLong(out, 4, _messageId); diff --git a/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java b/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java index acb602bfc..348c05e02 100644 --- a/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java +++ b/core/java/src/net/i2p/data/i2cp/MessagePayloadMessage.java @@ -61,6 +61,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl { _payload = payload; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = DataHelper.readLong(in, 2); @@ -72,6 +73,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { throw new RuntimeException("go away, we dont want any"); } @@ -104,6 +106,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl { } } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java b/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java index 30c9cd228..5cebb092f 100644 --- a/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java +++ b/core/java/src/net/i2p/data/i2cp/MessageStatusMessage.java @@ -106,6 +106,7 @@ public class MessageStatusMessage extends I2CPMessageImpl { } } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = DataHelper.readLong(in, 2); @@ -144,10 +145,12 @@ public class MessageStatusMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { throw new UnsupportedOperationException("This shouldn't be called... use writeMessage(out)"); } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java b/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java index cdcf2e078..f831687e2 100644 --- a/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReceiveMessageBeginMessage.java @@ -50,6 +50,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl { _messageId = id; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = DataHelper.readLong(in, 2); @@ -59,6 +60,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { throw new UnsupportedOperationException("This shouldn't be called... use writeMessage(out)"); } @@ -83,7 +85,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl { } } - + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java b/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java index c8a5be8ad..385e93a97 100644 --- a/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReceiveMessageEndMessage.java @@ -49,6 +49,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl { _messageId = id; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = DataHelper.readLong(in, 2); @@ -58,6 +59,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if ((_sessionId < 0) || (_messageId < 0)) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); @@ -67,6 +69,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl { return rv; } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java b/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java index 101406491..9a9b012d2 100644 --- a/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java +++ b/core/java/src/net/i2p/data/i2cp/ReportAbuseMessage.java @@ -70,6 +70,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl { _messageId = id; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); @@ -85,6 +86,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if ((_sessionId == null) || (_severity == null) || (_reason == null)) throw new I2CPMessageException("Not enough information to construct the message"); @@ -104,6 +106,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl { return os.toByteArray(); } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java b/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java index 20703a894..d095f4fac 100644 --- a/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java +++ b/core/java/src/net/i2p/data/i2cp/RequestLeaseSetMessage.java @@ -81,6 +81,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl { _end = end; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); @@ -100,6 +101,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if ((_sessionId == null) || (_endpoints == null)) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); @@ -120,6 +122,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl { return os.toByteArray(); } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java b/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java index f23569c07..c3a21a122 100644 --- a/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java +++ b/core/java/src/net/i2p/data/i2cp/SendMessageMessage.java @@ -72,6 +72,7 @@ public class SendMessageMessage extends I2CPMessageImpl { _nonce = nonce; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { if (true) throw new IllegalStateException("wtf, do not run me"); } @@ -101,6 +102,7 @@ public class SendMessageMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { throw new RuntimeException("wtf, dont run me"); } @@ -129,6 +131,7 @@ public class SendMessageMessage extends I2CPMessageImpl { } } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/SessionConfig.java b/core/java/src/net/i2p/data/i2cp/SessionConfig.java index d16ffe126..8a41f3428 100644 --- a/core/java/src/net/i2p/data/i2cp/SessionConfig.java +++ b/core/java/src/net/i2p/data/i2cp/SessionConfig.java @@ -185,6 +185,7 @@ public class SessionConfig extends DataStructureImpl { return out.toByteArray(); } + @Override public void readBytes(InputStream rawConfig) throws DataFormatException, IOException { _destination = new Destination(); _destination.readBytes(rawConfig); @@ -194,6 +195,7 @@ public class SessionConfig extends DataStructureImpl { _signature.readBytes(rawConfig); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_destination == null) || (_options == null) || (_signature == null) || (_creationDate == null)) throw new DataFormatException("Not enough data to create the session config"); diff --git a/core/java/src/net/i2p/data/i2cp/SessionId.java b/core/java/src/net/i2p/data/i2cp/SessionId.java index d4c75ea5f..d099852a5 100644 --- a/core/java/src/net/i2p/data/i2cp/SessionId.java +++ b/core/java/src/net/i2p/data/i2cp/SessionId.java @@ -40,10 +40,12 @@ public class SessionId extends DataStructureImpl { _sessionId = id; } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _sessionId = (int) DataHelper.readLong(in, 2); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_sessionId < 0) throw new DataFormatException("Invalid session ID: " + _sessionId); DataHelper.writeLong(out, 2, _sessionId); diff --git a/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java b/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java index 673181d12..1a060b523 100644 --- a/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java +++ b/core/java/src/net/i2p/data/i2cp/SessionStatusMessage.java @@ -55,6 +55,7 @@ public class SessionStatusMessage extends I2CPMessageImpl { _status = status; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); @@ -65,6 +66,7 @@ public class SessionStatusMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionId == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); @@ -78,6 +80,7 @@ public class SessionStatusMessage extends I2CPMessageImpl { return os.toByteArray(); } + @Override public int getType() { return MESSAGE_TYPE; } diff --git a/core/java/src/net/i2p/data/i2cp/SetDateMessage.java b/core/java/src/net/i2p/data/i2cp/SetDateMessage.java index f77664293..b441dee56 100644 --- a/core/java/src/net/i2p/data/i2cp/SetDateMessage.java +++ b/core/java/src/net/i2p/data/i2cp/SetDateMessage.java @@ -41,6 +41,7 @@ public class SetDateMessage extends I2CPMessageImpl { _date = date; } + @Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _date = DataHelper.readDate(in); @@ -49,6 +50,7 @@ public class SetDateMessage extends I2CPMessageImpl { } } + @Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_date == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); @@ -61,6 +63,7 @@ public class SetDateMessage extends I2CPMessageImpl { return os.toByteArray(); } + @Override public int getType() { return MESSAGE_TYPE; }