java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.HostLookupMessage
- All Implemented Interfaces:
I2CPMessage
Request the router look up the dest for a hash or a host. Replaces DestLookupMessage. Do not send to routers older than 0.9.11.
Field Summary
Modifier and TypeFieldDescriptionprivate HashThe hash to look up, for hash lookups.private StringThe host name to look up, for name lookups.private intWhat kind of lookup to perform.private longId matching the reply to the request.private SessionIdThe session that asked for the lookup.private longHow long the router may take, in ms.static final intLookup type value asking for the Destination behind a hash.static final intLookup type value asking for the HostName behind a Destination.private static final longLargest id that fits on the wire.static final intI2CP message type number of a host or hash lookup request.Constructor Summary
ConstructorsConstructorDescriptionCreates a lookup request with no target, type or session set.HostLookupMessage(SessionId id, String host, long reqID, long timeout) Session id.HostLookupMessage(SessionId id, Hash h, long reqID, long timeout) Session id.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.getHash()Gets the hash for hash-type lookups.Gets the hostname for host-type lookups.intThe lookup type selector.longgetReqID()Gets the request ID.Session making the lookup request.longGets the lookup timeout.intgetType()Reports this message as a host lookup request.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_TYPEI2CP message type number of a host or hash lookup request.- See Also:
_reqID
private long _reqIDId matching the reply to the request._timeout
private long _timeoutHow long the router may take, in ms._lookupType
private int _lookupTypeWhat kind of lookup to perform._hash
The hash to look up, for hash lookups._host
The host name to look up, for name lookups._sessionId
The session that asked for the lookup.LOOKUP_HASH
public static final int LOOKUP_HASHLookup type value asking for the Destination behind a hash.- See Also:
LOOKUP_HOST
public static final int LOOKUP_HOSTLookup type value asking for the HostName behind a Destination.- See Also:
MAX_INT
Constructor Details
HostLookupMessage
public HostLookupMessage()Creates a lookup request with no target, type or session set.HostLookupMessage
HostLookupMessage
Method Details
getSessionId
Session making the lookup request.- 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()Gets the request ID.- Returns:
- 0 to 2**32 - 1
getTimeout
public long getTimeout()Gets the lookup timeout.- Returns:
- ms 1 to 2**32 - 1
getLookupType
public int getLookupType()The lookup type selector.- Returns:
- 0 (hash) or 1 (host)
getHash
getHostname
Gets the hostname for host-type lookups.- Returns:
- only valid if lookup type == 1
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
toString