java.lang.Object
net.i2p.client.datagram.Datagram2

public class Datagram2extends Object
Class for creating and loading I2P repliable datagrams version 2. Ref: Proposal 163.
+----+----+----+----+----+----+----+----+
|                                       |
~            from                       ~
~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
|  flags  |     options (optional)      |
+----+----+                             +
~                                       ~
~                                       ~
+----+----+----+----+----+----+----+----+
|                                       |
~     offline_signature (optional)      ~
~   expires, sigtype, pubkey, offsig    ~
|                                       |
+----+----+----+----+----+----+----+----+
|                                       |
~            payload                    ~
~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
|                                       |
~            signature                  ~
~                                       ~
|                                       |
+----+----+----+----+----+----+----+----+
  • Field Details

    • _from

      private final Destination _from
      The sender of the datagram.
    • _payload

      private final byte[] _payload
      The data carried by the datagram.
    • _options

      private final Properties _options
      The options sent along with the datagram.
    • MIN_DGRAM_SIZE

      private static final int MIN_DGRAM_SIZE
      Smallest datagram that can be parsed.
      See Also:
    • MAX_DGRAM_BUFSIZE

      private static final int MAX_DGRAM_BUFSIZE
      Largest datagram buffer allocated.
      See Also:
    • VERSION_MASK

      private static final byte VERSION_MASK
      Mask for the version bits of the first byte.
      See Also:
    • OPTIONS

      private static final byte OPTIONS
      Flag saying the options follow.
      See Also:
    • OFFLINE

      private static final byte OFFLINE
      Flag saying the signature is offline.
      See Also:
    • VERSION

      private static final byte VERSION
      The version of this datagram format.
      See Also:
  • Constructor Details

  • Method Details

    • make

      public static byte[] make(I2PAppContext ctx, I2PSession session, byte[] payload, Hash tohash) throws DataFormatException
      Make a repliable I2P datagram2 containing the specified payload.
      Parameters:
      ctx - the I2P app context
      session - the I2P session
      payload - non-null Bytes to be contained in the I2P datagram.
      tohash - the destination hash
      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, Hash tohash, Properties options) throws DataFormatException
      Make a repliable I2P datagram2 containing the specified payload.
      Parameters:
      ctx - the I2P app context
      session - the I2P session
      payload - non-null Bytes to be contained in the I2P datagram.
      tohash - the destination hash
      options - may be null
      Returns:
      non-null, throws on all errors
      Throws:
      DataFormatException - if payload is too big
    • load

      public static Datagram2 load(I2PAppContext ctx, I2PSession session, byte[] dgram) throws DataFormatException, I2PInvalidDatagramException
      Load an I2P repliable datagram and verify the signature.
      Parameters:
      ctx - the I2P app context
      session - the I2P session
      dgram - 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
      I2PInvalidDatagramException - If the signature fails
    • 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

      public Destination getSender()
      The sender of an I2P repliable datagram (previously loaded with the load() method).
      Returns:
      The Destination of the I2P repliable datagram sender
    • getOptions

      public Properties getOptions()
      The options of an I2P repliable datagram (previously loaded with the load() method), if any.
      Returns:
      options or null