java.lang.Object
net.i2p.client.datagram.Datagram3
Class for creating and loading I2P repliable datagrams version 3. Ref: Proposal 163.
+----+----+----+----+----+----+----+----+ | | + fromHash + | | + + | | +----+----+----+----+----+----+----+----+ | flags | options (optional) | +----+----+ + ~ ~ ~ ~ +----+----+----+----+----+----+----+----+ | | ~ payload ~ ~ ~ | | +----+----+----+----+----+----+----+----+
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashThe sender's hash.private final PropertiesThe options sent along with the datagram.private final byte[]The data carried by the datagram.private static final intLargest datagram buffer allocated.private static final intSmallest datagram that can be parsed.private static final byteFlag saying the options follow.private static final byteThe version of this datagram format.private static final byteMask for the version bits of the first byte.Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDatagram3(Hash dest, byte[] data, Properties options) As returned fromload(I2PAppContext, I2PSession, byte[]).Method Summary
Modifier and TypeMethodDescriptionThe options of an I2P repliable datagram (previously loaded with the load() method), if any.byte[]The payload carried by an I2P repliable datagram (previously loaded with the load() method).The sender of an I2P repliable datagram (previously loaded with the load() method).static Datagram3load(I2PAppContext ctx, I2PSession session, byte[] dgram) Load an I2P repliable datagram3.static byte[]make(I2PAppContext ctx, I2PSession session, byte[] payload) Make a repliable I2P datagram3 containing the specified payload.static byte[]make(I2PAppContext ctx, I2PSession session, byte[] payload, Properties options) Make a repliable I2P datagram3 containing the specified payload.
Field Details
_from
The sender's hash._payload
private final byte[] _payloadThe data carried by the datagram._options
The options sent along with the datagram.MIN_DGRAM_SIZE
private static final int MIN_DGRAM_SIZESmallest datagram that can be parsed.- See Also:
MAX_DGRAM_BUFSIZE
private static final int MAX_DGRAM_BUFSIZELargest datagram buffer allocated.- See Also:
VERSION_MASK
private static final byte VERSION_MASKMask for the version bits of the first byte.- See Also:
OPTIONS
VERSION
Constructor Details
Datagram3
As returned fromload(I2PAppContext, I2PSession, byte[]).- Parameters:
dest- the sender's hashdata- the data carried by the datagramoptions- the options sent with the datagram
Method Details
make
public static byte[] make(I2PAppContext ctx, I2PSession session, byte[] payload) throws DataFormatException Make a repliable I2P datagram3 containing the specified payload.- Parameters:
ctx- non-nullsession- non-nullpayload- non-null Bytes to be contained in the I2P datagram.- Returns:
- non-null, throws on all errors
- Throws:
DataFormatException- if payload is too big
make
public static byte[] make(I2PAppContext ctx, I2PSession session, byte[] payload, Properties options) throws DataFormatException Make a repliable I2P datagram3 containing the specified payload.- Parameters:
ctx- non-nullsession- non-nullpayload- non-null Bytes to be contained in the I2P datagram.options- may be null- Returns:
- non-null, throws on all errors
- Throws:
DataFormatException- if payload is too big
load
public static Datagram3 load(I2PAppContext ctx, I2PSession session, byte[] dgram) throws DataFormatException Load an I2P repliable datagram3.- Parameters:
ctx- non-nullsession- non-nulldgram- non-null I2P repliable datagram to be loaded- Returns:
- non-null, throws on all errors
- Throws:
DataFormatException- If there is an error in the datagram format
getPayload
public byte[] getPayload()The payload carried by an I2P repliable datagram (previously loaded with the load() method).- Returns:
- A byte array containing the datagram payload
getSender
The sender of an I2P repliable datagram (previously loaded with the load() method).- Returns:
- The Hash of the Destination of the I2P repliable datagram sender
getOptions
The options of an I2P repliable datagram (previously loaded with the load() method), if any.- Returns:
- options or null