net.i2p.client.datagram
Class I2PDatagramMaker

java.lang.Object
  extended by net.i2p.client.datagram.I2PDatagramMaker

public final class I2PDatagramMaker
extends Object

Class for creating I2P repliable datagrams. Note that objects of this class are NOT THREAD SAFE!

Author:
human

Constructor Summary
I2PDatagramMaker()
          Construct a new I2PDatagramMaker that is null.
I2PDatagramMaker(I2PSession session)
          Construct a new I2PDatagramMaker that will be able to create I2P repliable datagrams going to be sent through the specified I2PSession.
 
Method Summary
 byte[] makeI2PDatagram(byte[] payload)
          Make a repliable I2P datagram containing the specified payload.
 void setI2PDatagramMaker(I2PSession session)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

I2PDatagramMaker

public I2PDatagramMaker(I2PSession session)
Construct a new I2PDatagramMaker that will be able to create I2P repliable datagrams going to be sent through the specified I2PSession.

Parameters:
session - I2PSession used to send I2PDatagrams through

I2PDatagramMaker

public I2PDatagramMaker()
Construct a new I2PDatagramMaker that is null. Use setI2PDatagramMaker to set the parameters.

Method Detail

setI2PDatagramMaker

public void setI2PDatagramMaker(I2PSession session)

makeI2PDatagram

public byte[] makeI2PDatagram(byte[] payload)
Make a repliable I2P datagram containing the specified payload. Format is:
  1. Destination (387+ bytes)
  2. Signature (40+ bytes, type and length as implied by signing key type in the Destination)
  3. Payload
Maximum datagram size is 32768, so maximum payload size is 32341, or less for non-DSA_SHA1 destinations. Practical maximum is a few KB less due to ElGamal/AES overhead. 10 KB or less is recommended for best results. For DSA_SHA1 Destinations, the signature is of the SHA-256 Hash of the payload. As of 0.9.14, for non-DSA_SHA1 Destinations, the signature is of the payload itself.

Parameters:
payload - non-null Bytes to be contained in the I2P datagram.
Returns:
null on error
Throws:
IllegalArgumentException - if payload is too big
IllegalStateException - if Destination signature type unsupported