public interface I2NPMessage extends DataStructure
Modifier and Type | Field and Description |
---|---|
static long |
MAX_ID_VALUE
4 bytes unsigned
|
static int |
MAX_SIZE
Nominal limit, actual max is much less.
|
Modifier and Type | Method and 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 header
|
int |
getType()
Return the unique identifier for this type of I2NP message, as defined in
the I2NP spec
|
long |
getUniqueId()
Replay resistant message ID
|
int |
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 specification
|
int |
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 specification
|
int |
readBytes(InputStream in,
int type,
byte[] buffer)
Deprecated.
unused
|
void |
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 specification
|
void |
readMessage(byte[] data,
int offset,
int dataSize,
int type,
I2NPMessageHandler handler) |
void |
setMessageExpiration(long exp) |
void |
setUniqueId(long id) |
int |
toByteArray(byte[] buffer)
write the message to the buffer, returning the number of bytes written.
|
int |
toRawByteArray(byte[] buffer)
write the message to the buffer, returning the number of bytes written.
|
calculateHash, fromBase64, fromByteArray, readBytes, toBase64, toByteArray, writeBytes
static final long MAX_ID_VALUE
static final int MAX_SIZE
@Deprecated int readBytes(InputStream in, int type, byte[] buffer) throws I2NPMessageException, IOException
in
- stream to read from
starting at type if type is < 0 (16 byte header)
starting at ID if type is >= 0 (15 byte header)type
- I2NP message type. If less than zero, read the type from databuffer
- scratch buffer to be used when reading and parsingI2NPMessageException
- if the stream doesn't contain a valid message
that this class can read.IOException
- if there is a problem reading from the streamint readBytes(byte[] data, int type, int offset) throws I2NPMessageException
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)I2NPMessageException
- if there is no valid messageint readBytes(byte[] data, int type, int offset, int maxLen) throws I2NPMessageException
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 < 0I2NPMessageException
- if there is no valid messagevoid readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException
data
- data to read fromoffset
- where to start in the data arraydataSize
- how long into the data to readtype
- I2NP message typeI2NPMessageException
- if the stream doesn't contain a valid message
that this class can read.void readMessage(byte[] data, int offset, int dataSize, int type, I2NPMessageHandler handler) throws I2NPMessageException
I2NPMessageException
int getType()
long getUniqueId()
void setUniqueId(long id)
long getMessageExpiration()
void setMessageExpiration(long exp)
int getMessageSize()
int getRawMessageSize()
int toByteArray(byte[] buffer)
int toRawByteArray(byte[] buffer)