All Implemented Interfaces:
Serializable, DataStructure

public class SendMessageOptionsextends DateAndFlags
Advanced options attached to a single outgoing I2CP message.

Note that the packing of options into the 16-bit flags field is is subject to change. Therefore, for now, this is only recommended within RouterContext.

Static methods are for OutboundClientMessageOneShotJob to decode the flags field on the router side.

GzipOption flags are as of 0.9.36, are client-side only, and are not included in the flags field or sent to the router.

See Also:
  • Field Details

    • _gzip

      Gzip compression option for this message.
    • LS_MASK

      private static final int LS_MASK
      1 means don't send, 0 means default.
      See Also:
    • TAGS_SEND_MASK

      private static final int TAGS_SEND_MASK
      Tags to send field, see below for possible values.
      See Also:
    • TAGS_SEND

      private static final int[] TAGS_SEND
      Possible values. Configured values will be rounded down. Note that ElGamalAESEngine enforces a max of 200 on receive.
    • TAGS_REQD_MASK

      private static final int TAGS_REQD_MASK
      Tags threshold field, see below for possible values.
      See Also:
    • TAGS_REQD

      private static final int[] TAGS_REQD
      Possible values. Configured values will be rounded down.
    • BEST_EFFORT_MASK

      private static final int BEST_EFFORT_MASK
      Best effort delivery mask.
      See Also:
    • GUARANTEED_MASK

      private static final int GUARANTEED_MASK
      Guaranteed delivery mask.
      See Also:
    • RELIABILITY_MASK

      private static final int RELIABILITY_MASK
      Reliability mask.
      See Also:
    • FRESH_CONNECTION_MASK

      private static final int FRESH_CONNECTION_MASK
      Mask for "first packet of a new connection" (streaming SYN first send).
      See Also:
  • Constructor Details

    • SendMessageOptions

      public SendMessageOptions()
      A message carrying default options: gzip is left at GzipOption.DEFAULT and the inherited date and flag fields are unset.
  • Method Details

    • setSendLeaseSet

      public void setSendLeaseSet(boolean yes)
      Send the lease set with the message; defaults to true.
      Parameters:
      yes - true to include the lease set, false to suppress it
    • getSendLeaseSet

      public boolean getSendLeaseSet()
      Whether the lease set is sent with the message; defaults to true.
      Returns:
      true unless the flag suppressing the lease set has been set
    • getSendLeaseSet

      public static boolean getSendLeaseSet(int flags)
      Whether the lease set is sent with the message; defaults to true.
      Parameters:
      flags - the packed flags word
      Returns:
      true unless the flag suppressing the lease set has been set
    • setTagsToSend

      public void setTagsToSend(int tags)
      If we are low on tags, send this many. Power of 2 recommended - rounds down. default 0, meaning unset, use the SKM config (default 40).
      Parameters:
      tags - 0 or 2 to 128
    • getTagsToSend

      public int getTagsToSend()
      If we are low on tags, send this many.
      Returns:
      default 0, meaning unset, use the SKM config (default 40)
    • getTagsToSend

      public static int getTagsToSend(int flags)
      If we are low on tags, send this many.
      Parameters:
      flags - the packed flags word
      Returns:
      default 0, meaning unset, use the SKM config (default 40)
    • setTagThreshold

      public void setTagThreshold(int tags)
      Low tag threshold. If less than this many, send more. Power of 2 recommended - rounds down. default 0, meaning unset, use the SKM config (default 30).
      Parameters:
      tags - 0 to 90
    • getTagThreshold

      public int getTagThreshold()
      Low tag threshold. If less than this many, send more.
      Returns:
      default 0, meaning unset, use the SKM config (default 30)
    • getTagThreshold

      public static int getTagThreshold(int flags)
      Low tag threshold. If less than this many, send more.
      Parameters:
      flags - the packed flags word
      Returns:
      default 0, meaning unset, use the SKM config (default 30)
    • valToCode

      private static int valToCode(int val, int[] codes)
      Round the value down to the nearest code in the array.
      Parameters:
      val - the value to round; a positive value at or below codes[1] rounds up to 1 so it does not become the default
      codes - the ascending table of possible values, index 0 being the unset default
      Returns:
      the index of the largest code not exceeding val, or the last index if val exceeds them all; 0 for a non-positive val
    • codeToVal

      private static int codeToVal(int code, int[] codes)
      The priority value stored at an index of the options table.
      Parameters:
      code - the index to read
      codes - the table of values
      Returns:
      the value at that index
    • setReliability

      public void setReliability(SendMessageOptions.Reliability r)
      Message delivery reliability.
      Parameters:
      r - reliability (default DEFAULT)
    • getReliability

      public SendMessageOptions.Reliability getReliability()
      Message delivery reliability.
      Returns:
      reliability (default DEFAULT)
    • setFreshConnection

      public void setFreshConnection(boolean yes)
      Mark this message as the first packet of a brand-new connection (the first transmission of a streaming SYN). Router-side only: OutboundClientMessageOneShotJob decodes it and prefers a different outbound tunnel, so a retry does not ride whatever tunnel stalled the previous connection. Only meaningful when set by an in-process sender (e.g. apps/streaming PacketQueue); see the class javadoc.
      Parameters:
      yes - true to mark the message as the first packet of a brand-new connection
    • getFreshConnection

      public boolean getFreshConnection()
      Whether this message is the first packet of a new connection.
      Returns:
      true if this message opens a new connection
    • getFreshConnection

      public static boolean getFreshConnection(int flags)
      Decode the fresh-connection marker from the raw flags field (router side).
      Parameters:
      flags - the raw flags field from the I2CP message header
      Returns:
      true if the message opens a new connection
    • getReliability

      public static SendMessageOptions.Reliability getReliability(int flags)
      Message delivery reliability from raw flags.
      Parameters:
      flags - the raw flags field from the I2CP message header
      Returns:
      reliability (default DEFAULT)
    • getGzip

      Gzip compression setting.
      Returns:
      non-null, DEFAULT unless setGzip(boolean) was called
    • setGzip

      public void setGzip(boolean yes)
      Enable or disable gzip compression.
      Parameters:
      yes - GZIP_ON if true, GZIP_OFF if false