java.lang.Object
net.i2p.data.DataStructureImpl
net.i2p.data.DateAndFlags
net.i2p.client.SendMessageOptions
- All Implemented Interfaces:
Serializable, DataStructure
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:
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOverridesi2cp.gzipsession option and size threshold for this message only.static enumReliability bits 9-10.Field Summary
FieldsModifier and TypeFieldDescriptionprivate SendMessageOptions.GzipOptionGzip compression option for this message.private static final intBest effort delivery mask.private static final intMask for "first packet of a new connection" (streaming SYN first send).private static final intGuaranteed delivery mask.private static final int1 means don't send, 0 means default.private static final intReliability mask.private static final int[]Possible values.private static final intTags threshold field, see below for possible values.private static final int[]Possible values.private static final intTags to send field, see below for possible values.Fields inherited from class DateAndFlags
_flagsConstructor Summary
ConstructorsConstructorDescriptionA message carrying default options: gzip is left at GzipOption.DEFAULT and the inherited date and flag fields are unset.Method Summary
Modifier and TypeMethodDescriptionprivate static intcodeToVal(int code, int[] codes) The priority value stored at an index of the options table.booleanWhether this message is the first packet of a new connection.static booleangetFreshConnection(int flags) Decode the fresh-connection marker from the raw flags field (router side).getGzip()Gzip compression setting.Message delivery reliability.getReliability(int flags) Message delivery reliability from raw flags.booleanWhether the lease set is sent with the message; defaults to true.static booleangetSendLeaseSet(int flags) Whether the lease set is sent with the message; defaults to true.intIf we are low on tags, send this many.static intgetTagsToSend(int flags) If we are low on tags, send this many.intLow tag threshold.static intgetTagThreshold(int flags) Low tag threshold.voidsetFreshConnection(boolean yes) Mark this message as the first packet of a brand-new connection (the first transmission of a streaming SYN).voidsetGzip(boolean yes) Enable or disable gzip compression.voidMessage delivery reliability.voidsetSendLeaseSet(boolean yes) Send the lease set with the message; defaults to true.voidsetTagsToSend(int tags) If we are low on tags, send this many.voidsetTagThreshold(int tags) Low tag threshold.private static intvalToCode(int val, int[] codes) Round the value down to the nearest code in the array.Methods inherited from class DateAndFlags
equals, fromByteArray, getDate, getFlags, getTime, hashCode, readBytes, setDate, setDate, setFlags, toByteArray, toString, writeBytesModifier and TypeMethodDescriptionbooleanvoidfromByteArray(byte[] data) Overridden for efficiency.getDate()The Date object is created here, it is not cached.intgetFlags()0 - 65535.longgetTime()Date in milliseconds since epoch.inthashCode()voidreadBytes(InputStream in) Load up the current object with data from the given stream.voidsetDate(long date) Set the date from a long timestamp.voidSet the date from a Date object.voidsetFlags(int flags) Replace the 16-bit flags field.byte[]Overridden for efficiency.toString()voidwriteBytes(OutputStream out) Write out the data structure to the stream, using the format defined in the I2P data structure specification.Methods inherited from class DataStructureImpl
calculateHash, fromBase64, read, toBase64Modifier and TypeMethodDescriptionCalculate the SHA256 value of this object (useful for a few scenarios).voidfromBase64(String data) Load the structure from the provided base64 string.protected intread(InputStream in, byte[] target) Repeated reads until buffer is full or IOException is thrown.toBase64()Render the structure into modified base 64 notation.
Field Details
_gzip
Gzip compression option for this message.LS_MASK
TAGS_SEND_MASK
private static final int TAGS_SEND_MASKTags to send field, see below for possible values.- See Also:
TAGS_SEND
private static final int[] TAGS_SENDPossible 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_MASKTags threshold field, see below for possible values.- See Also:
TAGS_REQD
private static final int[] TAGS_REQDPossible values. Configured values will be rounded down.BEST_EFFORT_MASK
GUARANTEED_MASK
RELIABILITY_MASK
FRESH_CONNECTION_MASK
private static final int FRESH_CONNECTION_MASKMask 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 defaultcodes- 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 readcodes- the table of values- Returns:
- the value at that index
setReliability
Message delivery reliability.- Parameters:
r- reliability (default DEFAULT)
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
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