Package net.i2p.data.i2np
Interface I2NPMessage
- All Known Implementing Classes:
DatabaseLookupMessage
,DatabaseSearchReplyMessage
,DatabaseStoreMessage
,DataMessage
,DeliveryStatusMessage
,FastI2NPMessageImpl
,GarlicMessage
,I2NPMessageImpl
,InboundTunnelBuildMessage
,OutboundTunnelBuildReplyMessage
,ShortTunnelBuildMessage
,ShortTunnelBuildReplyMessage
,TunnelBuildMessage
,TunnelBuildMessageBase
,TunnelBuildReplyMessage
,TunnelDataMessage
,TunnelGatewayMessage
,UnknownI2NPMessage
,VariableTunnelBuildMessage
,VariableTunnelBuildReplyMessage
public interface I2NPMessage
Base interface for all I2NP messages
Note: No longer extends DataStructure as of 0.9.48
- Author:
- jrandom
-
Field Summary
Fields Modifier and Type Field Description static long
MAX_ID_VALUE
4 bytes unsignedstatic int
MAX_SIZE
Nominal limit, actual max is much less. -
Method Summary
Modifier and Type Method Description long
getMessageExpiration()
Date after which the message should be dropped (and the associated uniqueId forgotten)int
getMessageSize()
How large the message is, including any checksums, i.e.int
getRawMessageSize()
How large the raw message is with the short 5 byte headerint
getType()
Return the unique identifier for this type of I2NP message, as defined in the I2NP speclong
getUniqueId()
Replay resistant message IDint
readBytes(byte[] data, int type, int offset)
Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specificationint
readBytes(byte[] data, int type, int offset, int maxLen)
Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specificationvoid
readMessage(byte[] data, int offset, int dataSize, int type)
Read the body into the data structures, after the initial type byte and the uniqueId / expiration, using the current class's format as defined by the I2NP specificationvoid
readMessage(byte[] data, int offset, int dataSize, int type, I2NPMessageHandler handler)
void
setMessageExpiration(long exp)
void
setUniqueId(long id)
byte[]
toByteArray()
int
toByteArray(byte[] buffer)
Write the message to the buffer, returning the new offset (NOT the length).int
toByteArray(byte[] buffer, int off)
Write the message to the buffer, returning the new offset (NOT the length).int
toRawByteArray(byte[] buffer)
Write the message to the buffer, returning the new offset (NOT the length).int
toRawByteArrayNTCP2(byte[] buffer, int off)
Write the message to the buffer, returning the new offset (NOT the length).
-
Field Details
-
MAX_ID_VALUE
static final long MAX_ID_VALUE4 bytes unsigned- See Also:
- Constant Field Values
-
MAX_SIZE
static final int MAX_SIZENominal limit, actual max is much less. See website docs for further restrictions due to various overhead and limitations in encryption, fragmentation, and the transports.- See Also:
- Constant Field Values
-
-
Method Details
-
readBytes
Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification- Parameters:
data
- the datatype
- I2NP message type. If less than zero, read the type from dataoffset
- where to start starting at type if type is < 0 (16 byte header) starting at ID if type is >= 0 (15 byte header)- Returns:
- size of the message read (including headers)
- Throws:
I2NPMessageException
- if there is no valid message
-
readBytes
Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification- Parameters:
data
- the data, may or may not include the typetype
- I2NP message type. If less than zero, read the type from dataoffset
- where to start starting at type if type is < 0 (16 byte header) starting at ID if type is >= 0 (15 byte header)maxLen
- read no more than this many bytes from data starting at offset, even if it is longer This includes the type byte only if type < 0- Returns:
- size of the message read (including headers)
- Throws:
I2NPMessageException
- if there is no valid message- Since:
- 0.8.12
-
readMessage
Read the body into the data structures, after the initial type byte and the uniqueId / expiration, using the current class's format as defined by the I2NP specification- Parameters:
data
- data to read fromoffset
- where to start in the data arraydataSize
- how long into the data to readtype
- I2NP message type- Throws:
I2NPMessageException
- if the stream doesn't contain a valid message that this class can read.
-
readMessage
void readMessage(byte[] data, int offset, int dataSize, int type, I2NPMessageHandler handler) throws I2NPMessageException- Throws:
I2NPMessageException
-
getType
int getType()Return the unique identifier for this type of I2NP message, as defined in the I2NP spec -
getUniqueId
long getUniqueId()Replay resistant message ID -
setUniqueId
void setUniqueId(long id) -
getMessageExpiration
long getMessageExpiration()Date after which the message should be dropped (and the associated uniqueId forgotten) -
setMessageExpiration
void setMessageExpiration(long exp) -
getMessageSize
int getMessageSize()How large the message is, including any checksums, i.e. full 16 byte header -
getRawMessageSize
int getRawMessageSize()How large the raw message is with the short 5 byte header -
toByteArray
byte[] toByteArray()- Since:
- 0.9.48 from DataStructure
-
toByteArray
int toByteArray(byte[] buffer)Write the message to the buffer, returning the new offset (NOT the length). the data is formatted so as to be self contained, with the type, size, expiration, unique id, as well as a checksum bundled along. Full 16 byte header for NTCP 1.- Returns:
- the new offset (NOT the length)
-
toByteArray
int toByteArray(byte[] buffer, int off)Write the message to the buffer, returning the new offset (NOT the length). the data is formatted so as to be self contained, with the type, size, expiration, unique id, as well as a checksum bundled along. Full 16 byte header for NTCP 1.- Parameters:
off
- the offset to start writing at- Returns:
- the new offset (NOT the length)
- Since:
- 0.9.36
-
toRawByteArray
int toRawByteArray(byte[] buffer)Write the message to the buffer, returning the new offset (NOT the length). the data is is not self contained - it does not include the size, unique id, or any checksum, but does include the type and expiration. Short 5 byte header for SSU.- Returns:
- the length written
-
toRawByteArrayNTCP2
int toRawByteArrayNTCP2(byte[] buffer, int off)Write the message to the buffer, returning the new offset (NOT the length). the data is is not self contained - it does not include the size, unique id, or any checksum, but does include the type and expiration. Short 9 byte header for NTCP 2.- Parameters:
off
- the offset to start writing at- Returns:
- the new offset (NOT the length)
- Since:
- 0.9.36
-