java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.DestReplyMessage
- All Implemented Interfaces:
I2CPMessage
Response to DestLookupMessage. As of 0.8.3, the response may include the hash from the request, indicating a failure for a specific request. Payload may be empty (failure), a Hash (failure), or a Destination.
Field Summary
Modifier and TypeFieldDescriptionprivate DestinationThe destination found for the name.private HashHash of the destination being reported.static final intI2CP message type number of a destination lookup reply.Constructor Summary
ConstructorsConstructorDescriptionCreates a reply carrying no destination, for a failed lookup.Creates a reply naming the destination the lookup resolved to.Non-null with non-null data.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.Gets the destination this reply resolved to.getHash()Gets the hash of the destination.intgetType()Reports this message as a destination lookup reply.toString()Returns a string representation of this message.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, readMessage, sessionId, 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.Return the SessionId for this type of message.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_TYPEI2CP message type number of a destination lookup reply.- See Also:
_dest
The destination found for the name._hash
Hash of the destination being reported.
Constructor Details
DestReplyMessage
public DestReplyMessage()Creates a reply carrying no destination, for a failed lookup.DestReplyMessage
Creates a reply naming the destination the lookup resolved to.- Parameters:
d- the destination the lookup resolved to, or null if this reply reports a failure
DestReplyMessage
Non-null with non-null data.- Parameters:
h- non-null with non-null data
Method Details
getDestination
Gets the destination this reply resolved to.- Returns:
- the full destination the lookup resolved to, or null if this reply carries only a hash or reports a failure with an empty payload
getHash
Gets the hash of the destination.- Returns:
- the hash copied from the request, identifying which lookup failed, or null if this reply carries a full destination or an empty payload
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()Reports this message as a destination lookup reply.- Returns:
MESSAGE_TYPE, the I2CP message type number of a lookup reply
toString