Package net.i2p.data.i2np
Class UnknownI2NPMessage
- java.lang.Object
-
- net.i2p.data.i2np.I2NPMessageImpl
-
- net.i2p.data.i2np.FastI2NPMessageImpl
-
- net.i2p.data.i2np.UnknownI2NPMessage
-
- All Implemented Interfaces:
I2NPMessage
public class UnknownI2NPMessage extends FastI2NPMessageImpl
This is similar to DataMessage or GarlicMessage but with a variable message type. This is defined so routers can route messages they don't know about. We don't extend those classes so that any code that does (instanceof foo) won't return true for this type. Load tests use DataMessage, for example. Also, those classes include an additional length field that we can't use here. See InboundMessageDistributor. There is no setData() method, the only way to create one of these is to read it with readMessage() (i.e., it came from some other router) As of 0.8.12 this class is working. It is used at the IBGW to reduce the processing required. For zero-hop IB tunnels, the convert() method is used to reconstitute a standard message class.- Since:
- 0.7.12 but broken before 0.8.12
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.i2p.data.i2np.I2NPMessageImpl
I2NPMessageImpl.Builder
-
-
Field Summary
-
Fields inherited from class net.i2p.data.i2np.FastI2NPMessageImpl
_checksum, _hasChecksum
-
Fields inherited from class net.i2p.data.i2np.I2NPMessageImpl
_context, _expiration, _log, CHECKSUM_LENGTH, DEFAULT_EXPIRATION_MS, HEADER_LENGTH
-
Fields inherited from interface net.i2p.data.i2np.I2NPMessage
MAX_ID_VALUE, MAX_SIZE
-
-
Constructor Summary
Constructors Constructor Description UnknownI2NPMessage(I2PAppContext context, int type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcalculateWrittenLength()calculate the message body's length (not including the header and footerI2NPMessageconvert()Attempt to convert this message to a known message class.booleanequals(Object object)intgetType()Note that this returns the "true" type, so that the IBGW can correctly make drop decisions.inthashCode()voidreadMessage(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 specificationStringtoString()protected intwriteMessageBody(byte[] out, int curIndex)write the message body to the output array, starting at the given index-
Methods inherited from class net.i2p.data.i2np.FastI2NPMessageImpl
readBytes, toByteArray, toByteArrayWithSavedChecksum
-
Methods inherited from class net.i2p.data.i2np.I2NPMessageImpl
createMessage, fromRawByteArray, fromRawByteArrayNTCP2, getMessageExpiration, getMessageSize, getRawMessageSize, getUniqueId, readBytes, readBytes, readMessage, registerBuilder, setMessageExpiration, setUniqueId, toByteArray, toByteArray, toRawByteArray, toRawByteArrayNTCP2, writeBytes
-
-
-
-
Constructor Detail
-
UnknownI2NPMessage
public UnknownI2NPMessage(I2PAppContext context, int type)
- Parameters:
type- 0-255
-
-
Method Detail
-
readMessage
public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageExceptionDescription copied from interface:I2NPMessageRead 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:
IllegalStateException- if data previously set, to protect saved checksumI2NPMessageException- if the stream doesn't contain a valid message that this class can read.
-
calculateWrittenLength
protected int calculateWrittenLength()
calculate the message body's length (not including the header and footer- Specified by:
calculateWrittenLengthin classI2NPMessageImpl
-
writeMessageBody
protected int writeMessageBody(byte[] out, int curIndex)write the message body to the output array, starting at the given index- Specified by:
writeMessageBodyin classI2NPMessageImpl- Returns:
- the index into the array after the last byte written (NOT the length)
-
getType
public int getType()
Note that this returns the "true" type, so that the IBGW can correctly make drop decisions.- Returns:
- 0-255
-
convert
public I2NPMessage convert() throws I2NPMessageException
Attempt to convert this message to a known message class. This does the delayed verification using the saved checksum. Used by TunnelGatewayZeroHop.- Throws:
I2NPMessageException- if the conversion fails- Since:
- 0.8.12
-
-