DataStructure, I2NPMessageFastI2NPMessageImpl, TunnelBuildMessageBasepublic abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPMessage
| 修飾子とタイプ | クラス | 説明 |
|---|---|---|
static interface |
I2NPMessageImpl.Builder |
interface for extending the types of messages handled - unused
|
| 修飾子とタイプ | フィールド | 説明 |
|---|---|---|
protected I2PAppContext |
_context |
|
protected long |
_expiration |
|
protected Log |
_log |
|
protected long |
_uniqueId |
Warning, lazily initialized by readBytes(), writeBytes(), toByteArray(),
getUniqueId(), and setUniqueId(); otherwise will be -1.
|
static int |
CHECKSUM_LENGTH |
|
static long |
DEFAULT_EXPIRATION_MS |
|
static int |
HEADER_LENGTH |
16
|
MAX_ID_VALUE, MAX_SIZE| コンストラクタ | 説明 |
|---|---|
I2NPMessageImpl(I2PAppContext context) |
| 修飾子とタイプ | メソッド | 説明 |
|---|---|---|
protected abstract int |
calculateWrittenLength() |
calculate the message body's length (not including the header and footer
|
static I2NPMessage |
createMessage(I2PAppContext context,
int type) |
Yes, this is fairly ugly, but its the only place it ever happens.
|
static I2NPMessage |
fromRawByteArray(I2PAppContext ctx,
byte[] buffer,
int offset,
int len,
I2NPMessageHandler handler) |
Read the message with a short 5-byte header.
|
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() |
The raw header consists of a one-byte type and a 4-byte expiration in seconds only.
|
long |
getUniqueId() |
Replay resistant message Id
|
int |
readBytes(byte[] data,
int type,
int offset) |
Read the header, then read the rest into buffer, then call
readMessage in the implemented message type
|
int |
readBytes(byte[] data,
int type,
int offset,
int maxLen) |
Set a limit on the max to read from the data buffer, so that
we can use a large buffer but prevent the reader from reading off the end.
|
void |
readBytes(java.io.InputStream in) |
推奨されていません。
unused
|
int |
readBytes(java.io.InputStream in,
int type,
byte[] buffer) |
推奨されていません。
unused
|
void |
readMessage(byte[] data,
int offset,
int dataSize,
int type,
I2NPMessageHandler handler) |
|
static void |
registerBuilder(I2NPMessageImpl.Builder builder,
int type) |
推奨されていません。
unused
|
void |
setMessageExpiration(long exp) |
The expiration is set to one minute from now in the constructor but it can be overridden here.
|
void |
setUniqueId(long id) |
The ID is set to a random value when written but it can be overridden here.
|
byte[] |
toByteArray() |
|
int |
toByteArray(byte[] buffer) |
write the message to the buffer, returning the number of bytes written.
|
int |
toRawByteArray(byte[] buffer) |
Write the message with a short 5-byte header.
|
void |
writeBytes(java.io.OutputStream out) |
推奨されていません。
unused
|
protected abstract int |
writeMessageBody(byte[] out,
int curIndex) |
write the message body to the output array, starting at the given index.
|
calculateHash, fromBase64, fromByteArray, toBase64calculateHash, fromBase64, fromByteArray, read, toBase64getType, readMessageprotected final Log _log
protected final I2PAppContext _context
protected long _expiration
protected long _uniqueId
public static final long DEFAULT_EXPIRATION_MS
public static final int CHECKSUM_LENGTH
public static final int HEADER_LENGTH
public I2NPMessageImpl(I2PAppContext context)
@Deprecated public static final void registerBuilder(I2NPMessageImpl.Builder builder, int type)
@Deprecated
public void readBytes(java.io.InputStream in)
throws DataFormatException,
java.io.IOException
readBytes インタフェース内 DataStructurein - stream to read fromDataFormatException - if the data is improperly formattedjava.io.IOException - if there was a problem reading the stream@Deprecated
public int readBytes(java.io.InputStream in,
int type,
byte[] buffer)
throws I2NPMessageException,
java.io.IOException
Specifically:
1 byte type (if caller didn't read already, as specified by the type param
4 byte ID
8 byte expiration
2 byte size
1 byte checksum
size bytes of payload (read by readMessage() in implementation)
Unused - All transports provide encapsulation and so we have byte arrays available.readBytes インタフェース内 I2NPMessagetype - the message type or -1 if we should read it herebuffer - temp buffer to usein - stream to read from
starting at type if type is < 0 (16 byte header)
starting at ID if type is >= 0 (15 byte header)I2NPMessageException - if the stream doesn't contain a valid message
that this class can read.java.io.IOException - if there is a problem reading from the streampublic int readBytes(byte[] data,
int type,
int offset)
throws I2NPMessageException
Specifically:
1 byte type (if caller didn't read already, as specified by the type param
4 byte ID
8 byte expiration
2 byte size
1 byte checksum
size bytes of payload (read by readMessage() in implementation)
readBytes インタフェース内 I2NPMessagetype - the message type or -1 if we should read it heredata - the 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 messagepublic int readBytes(byte[] data,
int type,
int offset,
int maxLen)
throws I2NPMessageException
readBytes インタフェース内 I2NPMessagemaxLen - 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 < 0data - 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)I2NPMessageException - if there is no valid message@Deprecated
public void writeBytes(java.io.OutputStream out)
throws DataFormatException,
java.io.IOException
writeBytes インタフェース内 DataStructureout - stream to write toDataFormatException - if the data was incomplete or not yet ready to be writtenjava.io.IOException - if there was a problem writing to the streampublic long getUniqueId()
getUniqueId インタフェース内 I2NPMessagepublic void setUniqueId(long id)
setUniqueId インタフェース内 I2NPMessagepublic long getMessageExpiration()
getMessageExpiration インタフェース内 I2NPMessagepublic void setMessageExpiration(long exp)
setMessageExpiration インタフェース内 I2NPMessagepublic int getMessageSize()
I2NPMessagegetMessageSize インタフェース内 I2NPMessagepublic int getRawMessageSize()
getRawMessageSize インタフェース内 I2NPMessagepublic byte[] toByteArray()
toByteArray インタフェース内 DataStructuretoByteArray クラス内 DataStructureImplpublic int toByteArray(byte[] buffer)
I2NPMessagetoByteArray インタフェース内 I2NPMessageprotected abstract int calculateWrittenLength()
protected abstract int writeMessageBody(byte[] out,
int curIndex)
throws I2NPMessageException
I2NPMessageExceptionpublic int toRawByteArray(byte[] buffer)
toRawByteArray インタフェース内 I2NPMessagepublic void readMessage(byte[] data,
int offset,
int dataSize,
int type,
I2NPMessageHandler handler)
throws I2NPMessageException
readMessage インタフェース内 I2NPMessageI2NPMessageExceptionpublic static I2NPMessage fromRawByteArray(I2PAppContext ctx, byte[] buffer, int offset, int len, I2NPMessageHandler handler) throws I2NPMessageException
public static I2NPMessage createMessage(I2PAppContext context, int type) throws I2NPMessageException
I2NPMessageException