Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.data.i2np
Interface I2NPMessage

All Superinterfaces:
  DataStructure

All Known Implementing Classes:
  DatabaseLookupMessage, DatabaseSearchReplyMessage, DatabaseStoreMessage, DataMessage, DeliveryStatusMessage, GarlicMessage, I2NPMessageImpl, TunnelBuildMessage, TunnelBuildReplyMessage, TunnelDataMessage, TunnelGatewayMessage, UnknownI2NPMessage, VariableTunnelBuildMessage, VariableTunnelBuildReplyMessage

    public interface I2NPMessage

extends DataStructure

Base interface for all I2NP messages

Author:
  jrandom

Field Summary
`static long` | `MAX_ID_VALUE`
`static int` | `MAX_SIZE`

Method Summary
`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
`int` | `getRawMessageSize()` How large the raw message is
`int` | `getType()` Return the unique identifier for this type of I2NP message, as defined in the I2NP spec
`long` | `getUniqueId()` Replay resistent message Id
`int` | `readBytes(byte[] data, int type, int offset)`
`int` | `readBytes(InputStream in, int type, byte[] buffer)` Read the body into the data structures, after the initial type byte, using the current class's format as defined by the I2NP specification
`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.

Methods inherited from interface net.i2p.data.DataStructure
`calculateHash, fromBase64, fromByteArray, readBytes, toBase64, toByteArray, writeBytes`

Field Detail

### MAX_ID_VALUE

    static final long MAX_ID_VALUE

See Also:
  Constant Field Values

### MAX_SIZE

    static final int MAX_SIZE

See Also:
  Constant Field Values

Method Detail

### readBytes

    int readBytes(InputStream in,
                  int type,
                  byte[] buffer)
                  throws I2NPMessageException,
                         IOException

  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:
    `in` - stream to read from
    `type` - I2NP message type
    `buffer` - scratch buffer to be used when reading and parsing
  Returns:
    size of the message read (including headers)
  Throws:
    `I2NPMessageException` - if the stream doesn't contain a valid message that this class can read.
    `IOException` - if there is a problem reading from the stream

### readBytes

    int readBytes(byte[] data,
                  int type,
                  int offset)
                  throws I2NPMessageException,
                         IOException

  Throws:
    `I2NPMessageException`
    `IOException`

### readMessage

    void readMessage(byte[] data,
                     int offset,
                     int dataSize,
                     int type)
                     throws I2NPMessageException,
                            IOException

  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 from
    `offset` - where to start in the data array
    `dataSize` - how long into the data to read
    `type` - I2NP message type
  Throws:
    `I2NPMessageException` - if the stream doesn't contain a valid message that this class can read.
    `IOException` - if there is a problem reading from the stream

### readMessage

    void readMessage(byte[] data,
                     int offset,
                     int dataSize,
                     int type,
                     I2NPMessageHandler handler)
                     throws I2NPMessageException,
                            IOException

  Throws:
    `I2NPMessageException`
    `IOException`

### getType

    int getType()

  Return the unique identifier for this type of I2NP message, as defined in the I2NP spec

### getUniqueId

    long getUniqueId()

  Replay resistent 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

### getRawMessageSize

    int getRawMessageSize()

  How large the raw message is

### toByteArray

    int toByteArray(byte[] buffer)

  write the message to the buffer, returning the number of bytes written. the data is formatted so as to be self contained, with the type, size, expiration, unique id, as well as a checksum bundled along.

### toRawByteArray

    int toRawByteArray(byte[] buffer)

  write the message to the buffer, returning the number of bytes written. 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD