java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.HostReplyMessage
- All Implemented Interfaces:
I2CPMessage
Response to HostLookupMessage. Replaces DestReplyMessage.
Field Summary
Modifier and TypeFieldDescriptionprivate intResult of the lookup.private DestinationThe destination being replied with.private PropertiesOptions for opening the session.private longThe request this answers, as a number.private SessionIdThe session the reply belongs to.private static final longLargest request id that fits on the wire.static final intThe I2CP message type number for this message.static final intDecryption failure result code.static final intGeneric fail, other codes TBD.static final intRequest key required result code.static final intLeaseSet lookup failure result code.static final intUnsupported lookup type result code.static final intRequest secret and key required result code.static final intRequest secret required result code.static final intThe reply succeeded and the destination was accepted.Constructor Summary
ConstructorsConstructorDescriptionCreate an empty reply to be filled in by the reader.HostReplyMessage(SessionId id, int failureCode, long reqID) A message with a failure code and no Destination.HostReplyMessage(SessionId id, Destination d, long reqID, Properties options) A message with RESULT_SUCCESS and a non-null Destination.Method Summary
Public MethodsModifier and TypeMethodDescriptionprotected voiddoReadMessage(InputStream in, int size) Read the message body from the input stream.protected byte[]Write the message body to the output stream.The destination the host accepted, which the client now owns.Session config overrides carried by the reply.longgetReqID()The ID of the request this message answers.intWhy the host accepted or rejected the request.Session the reply belongs to.intgetType()Returns this message's I2CP type ID.Return the SessionId for this message.toString()Returns a string representation of this message.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, readMessage, writeBytes, writeMessageModifier and TypeMethodDescriptionvoidreadBytes(InputStream in) Read the message from the stream, wrapping I2CPMessageException inDataFormatException.voidValidate the type and size of the message, and then read the message into the data structures.voidreadMessage(InputStream in, int length, int type) Read the body into the data structures.voidwriteBytes(OutputStream out) Write the message to the stream, wrapping I2CPMessageException in DataFormatException.voidwriteMessage(OutputStream out) Write out the full message to the stream, including the 4 byte size and 1 byte type header.
Field Details
MESSAGE_TYPE
public static final int MESSAGE_TYPEThe I2CP message type number for this message.- See Also:
_dest
The destination being replied with._reqID
private long _reqIDThe request this answers, as a number._code
private int _codeResult of the lookup._sessionId
The session the reply belongs to._options
Options for opening the session.RESULT_SUCCESS
public static final int RESULT_SUCCESSThe reply succeeded and the destination was accepted.- See Also:
RESULT_FAILURE
RESULT_SECRET_REQUIRED
public static final int RESULT_SECRET_REQUIREDRequest secret required result code.- See Also:
RESULT_KEY_REQUIRED
public static final int RESULT_KEY_REQUIREDRequest key required result code.- See Also:
RESULT_SECRET_AND_KEY_REQUIRED
public static final int RESULT_SECRET_AND_KEY_REQUIREDRequest secret and key required result code.- See Also:
RESULT_DECRYPTION_FAILURE
public static final int RESULT_DECRYPTION_FAILUREDecryption failure result code.- See Also:
RESULT_LEASESET_LOOKUP_FAILURE
public static final int RESULT_LEASESET_LOOKUP_FAILURELeaseSet lookup failure result code.- See Also:
RESULT_LOOKUP_TYPE_UNSUPPORTED
public static final int RESULT_LOOKUP_TYPE_UNSUPPORTEDUnsupported lookup type result code.- See Also:
MAX_INT
private static final long MAX_INTLargest request id that fits on the wire.- See Also:
Constructor Details
HostReplyMessage
public HostReplyMessage()Create an empty reply to be filled in by the reader.HostReplyMessage
A message with RESULT_SUCCESS and a non-null Destination.- Parameters:
id- the session idd- non-nullreqID- 0 to 2**32 - 1options- for replies to lookup types 2-4, may be null, see proposal 167
HostReplyMessage
A message with a failure code and no Destination.- Parameters:
id- the session idfailureCode- 1-255reqID- from the HostLookup 0 to 2**32 - 1
Method Details
getSessionId
Session the reply belongs to.- Returns:
- the session id, null until set or read
sessionId
Return the SessionId for this message.- Specified by:
sessionIdin interfaceI2CPMessage- Overrides:
sessionIdin classI2CPMessageImpl- Returns:
- null always. Extending classes with a SessionId must override.
getReqID
public long getReqID()The ID of the request this message answers.- Returns:
- 0 to 2**32 - 1
getResultCode
public int getResultCode()Why the host accepted or rejected the request.- Returns:
- 0 on success, 1-255 on failure
getDestination
The destination the host accepted, which the client now owns.- Returns:
- non-null only if result code is zero
getOptions
Session config overrides carried by the reply.- Returns:
- non-null only if result code is zero and options are present
doReadMessage
Read the message body from the input stream.- Specified by:
doReadMessagein classI2CPMessageImpl- Parameters:
in- positioned just past the 4 byte size and 1 byte type headersize- how many payload bytes remain to be read- Throws:
I2CPMessageException- if the message format is invalidIOException- if there's an error reading from the stream
doWriteMessage
Write the message body to the output stream.- Specified by:
doWriteMessagein classI2CPMessageImpl- Returns:
- byte array
- Throws:
I2CPMessageException- if the message cannot be writtenIOException- if there's an error writing to the stream
getType
public int getType()Returns this message's I2CP type ID.- Returns:
- the I2CP message type ID,
MESSAGE_TYPE
toString