java.lang.Object
net.i2p.data.i2cp.I2CPMessageImpl
net.i2p.data.i2cp.MessageStatusMessage
- All Implemented Interfaces:
I2CPMessage
Defines the message a router sends to a client about a single message. For incoming messages, it tells the client that a new message is available. For outgoing messages, it tells the client whether the message was delivered.
Field Summary
Modifier and TypeFieldDescriptionprivate longThe message being reported on.private longThe nonce the message was sent with.private intThe session the message belongs to.private longSize of the message, in bytes.private intWhat happened to the message.static final intI2CP message type ID written to the wire header.static final intFor incoming messages.static final intThe router accepted the message for delivery, without guaranteeing success.static final intA probable failure, but we don't know for sure.static final intUnused best-effort success status code.static final intWe got the far-end leaseset but something strange is wrong with it.static final intThe message payload is invalid or zero-length or too big.static final intSomething is invalid in the message options, or the expiration is too far in the future.static final intThe session is invalid or closed.static final intSomething strange is wrong with the far-end destination.static final intMessage expired before it could be sent.static final intWe got the far-end leaseset but it's expired and can't get a new one.static final intThe far-end destination is local but delivery failed for some reason.static final intLocal leaseset problems.static final intMessage was attempted to be sent to the same Destination.static final intThe far-end destination's lease set was a meta lease set, and cannot be sent to.static final intThe PC apparently has no network connectivity at all.static final intCould not find the far-end destination's lease set.static final intLocal problems - no outbound tunnel to send through, or no inbound tunnel if a reply is required.static final intSome queue or buffer in the router is full and the message was dropped.static final intThe router is not ready, has shut down, or has major problems.static final intThe certs or options in the destination or leaseset indicate that it uses an encryption format that we don't support, so we can't talk to it.static final intGeneric failure, specific cause unknown.static final intGeneric success.static final intThe far-end destination is local and we are pretty darn sure the delivery succeeded.Constructor Summary
ConstructorsConstructorDescriptionNOTE: Add any new status codes to handlers in: net.i2p.client.impl.MessageState net.i2p.client.impl.MessageStatusMessageHandler net.i2p.client.streaming.I2PSocketException net.i2p.client.streaming.impl.PacketQueue net.i2p.i2ptunnel.I2PTunnelHTTPClientBase and update http://i2p-projekt.i2p/spec/i2cpMethod Summary
Modifier and TypeMethodDescriptionprotected voiddoReadMessage(InputStream in, int size) Read the message body from the input stream.protected byte[]Write the message body to the output stream.longThis is the router's ID for the message.longgetNonce()This is the client's ID for the message.longSession the status applies to.longgetSize()Size of the message payload as counted by the router.intStatus code describing what happened to the message.static final StringgetStatusString(int status) Human-readable name of a status constant.intgetType()I2CP message type sent for this message.booleanIs the status code a success status code?static booleanisSuccessful(int status) Is the status code a success status code?Return the SessionId for this message.voidsetMessageId(long id) This is the router's ID for the message.voidsetNonce(long nonce) This is the client's ID for the message.voidsetSessionId(long id) Session ID for this message.voidsetSize(long size) Size of the message data.voidsetStatus(int status) Status code for this message.toString()Returns a string representation of this message.voidwriteMessage(OutputStream out) Override to reduce mem churn.Methods inherited from class I2CPMessageImpl
readBytes, readMessage, readMessage, writeBytesModifier and TypeMethodDescriptionvoidreadBytes(InputStream in) Read the message from the stream, wrapping I2CPMessageException inDataFormatException.voidValidate the type and size of the message, and then read the message into the data structures.voidreadMessage(InputStream in, int length, int type) Read the body into the data structures.voidwriteBytes(OutputStream out) Write the message to the stream, wrapping I2CPMessageException in DataFormatException.
Field Details
MESSAGE_TYPE
public static final int MESSAGE_TYPEI2CP message type ID written to the wire header.- See Also:
_sessionId
private int _sessionIdThe session the message belongs to._messageId
private long _messageIdThe message being reported on._nonce
private long _nonceThe nonce the message was sent with._size
private long _sizeSize of the message, in bytes._status
private int _statusWhat happened to the message.STATUS_AVAILABLE
public static final int STATUS_AVAILABLEFor incoming messages. All the rest are for outgoing.- See Also:
STATUS_SEND_ACCEPTED
public static final int STATUS_SEND_ACCEPTEDThe router accepted the message for delivery, without guaranteeing success.- See Also:
STATUS_SEND_BEST_EFFORT_SUCCESS
public static final int STATUS_SEND_BEST_EFFORT_SUCCESSUnused best-effort success status code.- See Also:
STATUS_SEND_BEST_EFFORT_FAILURE
public static final int STATUS_SEND_BEST_EFFORT_FAILUREA probable failure, but we don't know for sure.- See Also:
STATUS_SEND_GUARANTEED_SUCCESS
public static final int STATUS_SEND_GUARANTEED_SUCCESSGeneric success. May not really be guaranteed, as the best-effort success code is unused.- See Also:
STATUS_SEND_GUARANTEED_FAILURE
public static final int STATUS_SEND_GUARANTEED_FAILUREGeneric failure, specific cause unknown. May not really be a guaranteed failure, as the best-effort failure code is unused.- See Also:
STATUS_SEND_SUCCESS_LOCAL
public static final int STATUS_SEND_SUCCESS_LOCALThe far-end destination is local and we are pretty darn sure the delivery succeeded.- See Also:
STATUS_SEND_FAILURE_LOCAL
public static final int STATUS_SEND_FAILURE_LOCALThe far-end destination is local but delivery failed for some reason. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_ROUTER
public static final int STATUS_SEND_FAILURE_ROUTERThe router is not ready, has shut down, or has major problems. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_NETWORK
public static final int STATUS_SEND_FAILURE_NETWORKThe PC apparently has no network connectivity at all. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_BAD_SESSION
public static final int STATUS_SEND_FAILURE_BAD_SESSIONThe session is invalid or closed. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_BAD_MESSAGE
public static final int STATUS_SEND_FAILURE_BAD_MESSAGEThe message payload is invalid or zero-length or too big. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_BAD_OPTIONS
public static final int STATUS_SEND_FAILURE_BAD_OPTIONSSomething is invalid in the message options, or the expiration is too far in the future. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_OVERFLOW
public static final int STATUS_SEND_FAILURE_OVERFLOWSome queue or buffer in the router is full and the message was dropped. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_EXPIRED
public static final int STATUS_SEND_FAILURE_EXPIREDMessage expired before it could be sent. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_LOCAL_LEASESET
public static final int STATUS_SEND_FAILURE_LOCAL_LEASESETLocal leaseset problems. The client has not yet signed a leaseset, or the local keys are invalid, or it has expired, or it does not have any tunnels in it. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_NO_TUNNELS
public static final int STATUS_SEND_FAILURE_NO_TUNNELSLocal problems - no outbound tunnel to send through, or no inbound tunnel if a reply is required. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_UNSUPPORTED_ENCRYPTION
public static final int STATUS_SEND_FAILURE_UNSUPPORTED_ENCRYPTIONThe certs or options in the destination or leaseset indicate that it uses an encryption format that we don't support, so we can't talk to it. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_DESTINATION
public static final int STATUS_SEND_FAILURE_DESTINATIONSomething strange is wrong with the far-end destination. Bad format, unsupported options, certificates, etc. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_BAD_LEASESET
public static final int STATUS_SEND_FAILURE_BAD_LEASESETWe got the far-end leaseset but something strange is wrong with it. Unsupported options or certificates, no tunnels, etc. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_EXPIRED_LEASESET
public static final int STATUS_SEND_FAILURE_EXPIRED_LEASESETWe got the far-end leaseset but it's expired and can't get a new one. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_NO_LEASESET
public static final int STATUS_SEND_FAILURE_NO_LEASESETCould not find the far-end destination's lease set. This is a common failure, equivalent to a DNS lookup fail. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_META_LEASESET
public static final int STATUS_SEND_FAILURE_META_LEASESETThe far-end destination's lease set was a meta lease set, and cannot be sent to. The client should request the meta lease set's contents with a HostLookupMessage, and select one of the hashes contained within to lookup and send to. This is a guaranteed failure.- See Also:
STATUS_SEND_FAILURE_LOOPBACK
public static final int STATUS_SEND_FAILURE_LOOPBACKMessage was attempted to be sent to the same Destination. This is a guaranteed failure.- See Also:
Constructor Details
MessageStatusMessage
public MessageStatusMessage()NOTE: Add any new status codes to handlers in: net.i2p.client.impl.MessageState net.i2p.client.impl.MessageStatusMessageHandler net.i2p.client.streaming.I2PSocketException net.i2p.client.streaming.impl.PacketQueue net.i2p.i2ptunnel.I2PTunnelHTTPClientBase and update http://i2p-projekt.i2p/spec/i2cp
Method Details
getSessionId
public long getSessionId()Session the status applies to.- Returns:
- the session id 0-65535, or -1 if not set
sessionId
Return the SessionId for this message.- Specified by:
sessionIdin interfaceI2CPMessage- Overrides:
sessionIdin classI2CPMessageImpl- Returns:
- null always. Extending classes with a SessionId must override.
setSessionId
public void setSessionId(long id) Session ID for this message.- Parameters:
id- 0-65535
getStatus
public int getStatus()Status code describing what happened to the message.- Returns:
- one of the STATUS_* constants
setStatus
public void setStatus(int status) Status code for this message.- Parameters:
status- 0-255
isSuccessful
public boolean isSuccessful()Is the status code a success status code?- Returns:
- true for STATUS_SEND_GUARANTEED_SUCCESS, STATUS_SEND_BEST_EFFORT_SUCCESS, STATUS_SEND_SUCCESS_LOCAL, STATUS_SEND_ACCEPTED or STATUS_AVAILABLE
isSuccessful
public static boolean isSuccessful(int status) Is the status code a success status code?- Parameters:
status- one of the STATUS_* constants to classify- Returns:
- true for the five STATUS_* success codes, false otherwise
getMessageId
public long getMessageId()This is the router's ID for the message.- Returns:
- the message id
setMessageId
public void setMessageId(long id) This is the router's ID for the message.- Parameters:
id- the router-assigned identifier of the message this status describes
getSize
public long getSize()Size of the message payload as counted by the router.- Returns:
- the payload size in bytes
setSize
public void setSize(long size) Size of the message data.- Parameters:
size- the payload size in bytes as counted by the router
getNonce
public long getNonce()This is the client's ID for the message.- Returns:
- the client-chosen nonce for this message
setNonce
public void setNonce(long nonce) This is the client's ID for the message.- Parameters:
nonce- the client-chosen identifier the router echoes back in this status
getStatusString
Human-readable name of a status constant.- Parameters:
status- the STATUS_* constant to translate- Returns:
- an upper-case string such as AVAILABLE, or SEND FAILURE CODE: n for unrecognized values
doReadMessage
Read the message body from the input stream.- Specified by:
doReadMessagein classI2CPMessageImpl- Parameters:
in- positioned just past the 4 byte size and 1 byte type headersize- how many payload bytes remain to be read- Throws:
I2CPMessageException- if the message format is invalidIOException- if there's an error reading from the stream
writeMessage
Override to reduce mem churn.- Specified by:
writeMessagein interfaceI2CPMessage- Overrides:
writeMessagein classI2CPMessageImpl- Parameters:
out- receives the length, type and payload, in that order- Throws:
IOException- if the stream rejects the written fieldsI2CPMessageException- if the current object doesn't have sufficient data to write a properly formatted message.
doWriteMessage
Write the message body to the output stream.- Specified by:
doWriteMessagein classI2CPMessageImpl- Returns:
- byte array
- Throws:
I2CPMessageException- if the message cannot be writtenIOException- if there's an error writing to the stream
getType
public int getType()I2CP message type sent for this message.- Returns:
- the fixed MESSAGE_TYPE of this class
toString