java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.RequestLeaseSetMessage
- All Implemented Interfaces:
I2CPMessage
Defines the message a router sends to a client to request that a leaseset be created and signed. The reply is a CreateLeaseSetMessage.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classOne tunnel endpoint of the lease set.Field Summary
Modifier and TypeFieldDescriptionprivate DateWhen the lease set expires.private final ArrayList<RequestLeaseSetMessage.TunnelEndpoint> The requested tunnel endpoints, an array list because list is not serializable.private SessionIdThe session asking for the lease set.static final intI2CP message type of a lease set request.private static final longThe serialization version of the message.Constructor Summary
ConstructorsMethod Summary
Public MethodsModifier and TypeMethodDescriptionvoidaddEndpoint(Hash router, TunnelId tunnel) Add a router and tunnel endpoint.protected voiddoReadMessage(InputStream in, int size) Read the message body from the input stream.protected byte[]Write the message body to the output stream.When the lease set should expire.intReturns the number of tunnels in the request.getRouter(int endpoint) Returns the router identity of one of the requested tunnels.Session requesting the lease set.getTunnelId(int endpoint) Tunnel of one of the requested endpoints.intgetType()Returns the I2CP message type of this message.Return the SessionId for this message.voidsetEndDate(Date end) End date of the lease set.voidSession ID 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
serialVersionUID
private static final long serialVersionUIDThe serialization version of the message.- See Also:
MESSAGE_TYPE
public static final int MESSAGE_TYPEI2CP message type of a lease set request.- See Also:
_sessionId
The session asking for the lease set._endpoints
The requested tunnel endpoints, an array list because list is not serializable._end
When the lease set expires.
Constructor Details
RequestLeaseSetMessage
public RequestLeaseSetMessage()Creates a request with an empty endpoint list.
Method Details
getSessionId
Session requesting the lease set.- 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.
setSessionId
Session ID for this message.- Parameters:
id- the session identifier to attach to this message
getEndpoints
public int getEndpoints()Returns the number of tunnels in the request.- Returns:
- the count of router/tunnel pairs requested
getRouter
Returns the router identity of one of the requested tunnels.- Parameters:
endpoint- index into the endpoint list; out of range returns null- Returns:
- the identity hash of the tunnel's gateway, or null if the index is out of range
getTunnelId
Tunnel of one of the requested endpoints.- Parameters:
endpoint- index into the endpoint list; out of range returns null- Returns:
- the endpoint's tunnel id, or null if the index is out of range
addEndpoint
getEndDate
When the lease set should expire.- Returns:
- the end date, null until set or read
setEndDate
End date of the lease set.- Parameters:
end- the expiry date requested for the lease set
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