Added JDK5 lint fixes
Streaming lib javadocs
This commit is contained in:
@ -574,7 +574,9 @@ public class Connection {
|
||||
}
|
||||
|
||||
private boolean _remotePeerSet = false;
|
||||
/** who are we talking with */
|
||||
/** who are we talking with
|
||||
* @return peer Destination
|
||||
*/
|
||||
public Destination getRemotePeer() { return _remotePeer; }
|
||||
public void setRemotePeer(Destination peer) {
|
||||
if (_remotePeerSet) throw new RuntimeException("Remote peer already set [" + _remotePeer + ", " + peer + "]");
|
||||
@ -583,7 +585,9 @@ public class Connection {
|
||||
}
|
||||
|
||||
private boolean _sendStreamIdSet = false;
|
||||
/** what stream do we send data to the peer on? */
|
||||
/** what stream do we send data to the peer on?
|
||||
* @return non-global stream sending ID
|
||||
*/
|
||||
public long getSendStreamId() { return _sendStreamId; }
|
||||
public void setSendStreamId(long id) {
|
||||
if (_sendStreamIdSet) throw new RuntimeException("Send stream ID already set [" + _sendStreamId + ", " + id + "]");
|
||||
@ -592,7 +596,9 @@ public class Connection {
|
||||
}
|
||||
|
||||
private boolean _receiveStreamIdSet = false;
|
||||
/** stream the peer sends data to us on. (may be null) */
|
||||
/** The stream ID of a peer connection that sends data to us. (may be null)
|
||||
* @return receive stream ID, or null if there isn't one
|
||||
*/
|
||||
public long getReceiveStreamId() { return _receiveStreamId; }
|
||||
public void setReceiveStreamId(long id) {
|
||||
if (_receiveStreamIdSet) throw new RuntimeException("Receive stream ID already set [" + _receiveStreamId + ", " + id + "]");
|
||||
@ -601,15 +607,33 @@ public class Connection {
|
||||
synchronized (_connectLock) { _connectLock.notifyAll(); }
|
||||
}
|
||||
|
||||
/** when did we last send anything to the peer? */
|
||||
/** When did we last send anything to the peer?
|
||||
* @return Last time we sent data
|
||||
*/
|
||||
public long getLastSendTime() { return _lastSendTime; }
|
||||
/** Set the time we sent data.
|
||||
* @param when The time we sent data
|
||||
*/
|
||||
public void setLastSendTime(long when) { _lastSendTime = when; }
|
||||
|
||||
/** what was the last packet Id sent to the peer? */
|
||||
/** What was the last packet Id sent to the peer?
|
||||
* @return The last sent packet ID
|
||||
*/
|
||||
public long getLastSendId() { return _lastSendId; }
|
||||
/** Set the packet Id that was sent to a peer.
|
||||
* @param id The packet ID
|
||||
*/
|
||||
public void setLastSendId(long id) { _lastSendId = id; }
|
||||
|
||||
/**
|
||||
* Retrieve the current ConnectionOptions.
|
||||
* @return the current ConnectionOptions
|
||||
*/
|
||||
public ConnectionOptions getOptions() { return _options; }
|
||||
/**
|
||||
* Set the ConnectionOptions.
|
||||
* @param opts ConnectionOptions
|
||||
*/
|
||||
public void setOptions(ConnectionOptions opts) { _options = opts; }
|
||||
|
||||
public I2PSession getSession() { return _connectionManager.getSession(); }
|
||||
@ -641,6 +665,7 @@ public class Connection {
|
||||
* Time when the scheduler next want to send a packet, or -1 if
|
||||
* never. This should be set when we want to send on timeout, for
|
||||
* instance, or want to delay an ACK.
|
||||
* @return the next time the scheduler will want to send a packet, or -1 if never.
|
||||
*/
|
||||
public long getNextSendTime() { return _nextSendTime; }
|
||||
public void setNextSendTime(long when) {
|
||||
@ -665,7 +690,9 @@ public class Connection {
|
||||
}
|
||||
}
|
||||
|
||||
/** how many packets have we sent and the other side has ACKed? */
|
||||
/** how many packets have we sent and the other side has ACKed?
|
||||
* @return Count of how many packets ACKed.
|
||||
*/
|
||||
public long getAckedPackets() { return _ackedPackets; }
|
||||
public long getCreatedOn() { return _createdOn; }
|
||||
public long getCloseSentOn() { return _closeSentOn; }
|
||||
@ -681,7 +708,9 @@ public class Connection {
|
||||
|
||||
public void incrementUnackedPacketsReceived() { _unackedPacketsReceived++; }
|
||||
public int getUnackedPacketsReceived() { return _unackedPacketsReceived; }
|
||||
/** how many packets have we sent but not yet received an ACK for? */
|
||||
/** how many packets have we sent but not yet received an ACK for?
|
||||
* @return Count of packets in-flight.
|
||||
*/
|
||||
public int getUnackedPacketsSent() {
|
||||
synchronized (_outboundPackets) {
|
||||
return _outboundPackets.size();
|
||||
@ -857,11 +886,16 @@ public class Connection {
|
||||
}
|
||||
}
|
||||
|
||||
/** stream that the local peer receives data on */
|
||||
/** stream that the local peer receives data on
|
||||
* @return the inbound message stream
|
||||
*/
|
||||
public MessageInputStream getInputStream() { return _inputStream; }
|
||||
/** stream that the local peer sends data to the remote peer on */
|
||||
/** stream that the local peer sends data to the remote peer on
|
||||
* @return the outbound message stream
|
||||
*/
|
||||
public MessageOutputStream getOutputStream() { return _outputStream; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
buf.append("[Connection ");
|
||||
@ -927,7 +961,7 @@ public class Connection {
|
||||
* fired to reschedule event notification
|
||||
*/
|
||||
class ConEvent implements SimpleTimer.TimedEvent {
|
||||
private Exception _addedBy;
|
||||
private Exception _addedBy; // unused?
|
||||
public ConEvent() {
|
||||
//_addedBy = new Exception("added by");
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class ConnectionManager {
|
||||
|
||||
/**
|
||||
* Get the socket accept() timeout.
|
||||
* @return
|
||||
* @return accept timeout in ms.
|
||||
*/
|
||||
public long MgetSoTimeout() {
|
||||
return SoTimeout;
|
||||
@ -121,6 +121,7 @@ public class ConnectionManager {
|
||||
/**
|
||||
* Create a new connection based on the SYN packet we received.
|
||||
*
|
||||
* @param synPacket SYN packet to process
|
||||
* @return created Connection with the packet's data already delivered to
|
||||
* it, or null if the syn's streamId was already taken
|
||||
*/
|
||||
@ -190,7 +191,9 @@ public class ConnectionManager {
|
||||
* Build a new connection to the given peer. This blocks if there is no
|
||||
* connection delay, otherwise it returns immediately.
|
||||
*
|
||||
* @return new connection, or null if we have exceeded our limit
|
||||
* @param peer Destination to contact
|
||||
* @param opts Connection's options
|
||||
* @return new connection, or null if we have exceeded our limit
|
||||
*/
|
||||
public Connection connect(Destination peer, ConnectionOptions opts) {
|
||||
Connection con = null;
|
||||
@ -293,6 +296,7 @@ public class ConnectionManager {
|
||||
/**
|
||||
* Drop the (already closed) connection on the floor.
|
||||
*
|
||||
* @param con Connection to drop.
|
||||
*/
|
||||
public void removeConnection(Connection con) {
|
||||
boolean removed = false;
|
||||
@ -319,7 +323,9 @@ public class ConnectionManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** return a set of Connection objects */
|
||||
/** return a set of Connection objects
|
||||
* @return set of Connection objects
|
||||
*/
|
||||
public Set listConnections() {
|
||||
synchronized (_connectionLock) {
|
||||
return new HashSet(_connectionByInboundId.values());
|
||||
|
@ -94,6 +94,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init(Properties opts) {
|
||||
super.init(opts);
|
||||
_trend = new int[TREND_COUNT];
|
||||
@ -118,6 +119,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
setConnectTimeout(getInt(opts, PROP_CONNECT_TIMEOUT, Connection.DISCONNECT_TIMEOUT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties opts) {
|
||||
super.setProperties(opts);
|
||||
if (opts == null) return;
|
||||
@ -164,6 +166,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* until the output stream is flushed, the buffer fills,
|
||||
* or that many milliseconds pass.
|
||||
*
|
||||
* @return how long to wait before actually attempting to connect
|
||||
*/
|
||||
public int getConnectDelay() { return _connectDelay; }
|
||||
public void setConnectDelay(int delayMs) { _connectDelay = delayMs; }
|
||||
@ -173,6 +176,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* or can we deal with signatures on the SYN and FIN packets
|
||||
* only?
|
||||
*
|
||||
* @return if we want signatures on all packets.
|
||||
*/
|
||||
public boolean getRequireFullySigned() { return _fullySigned; }
|
||||
public void setRequireFullySigned(boolean sign) { _fullySigned = sign; }
|
||||
@ -180,6 +184,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
/**
|
||||
* How many messages will we send before waiting for an ACK?
|
||||
*
|
||||
* @return Maximum amount of messages that can be in-flight
|
||||
*/
|
||||
public int getWindowSize() { return _windowSize; }
|
||||
public void setWindowSize(int numMsgs) {
|
||||
@ -195,12 +200,15 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
_windowSize = numMsgs;
|
||||
}
|
||||
|
||||
/** after how many consecutive messages should we ack? */
|
||||
/** after how many consecutive messages should we ack?
|
||||
* @return receive window size.
|
||||
*/
|
||||
public int getReceiveWindow() { return _receiveWindow; }
|
||||
public void setReceiveWindow(int numMsgs) { _receiveWindow = numMsgs; }
|
||||
|
||||
/**
|
||||
* What to set the round trip time estimate to (in milliseconds)
|
||||
* @return round trip time estimate in ms
|
||||
*/
|
||||
public int getRTT() { return _rtt; }
|
||||
public void setRTT(int ms) {
|
||||
@ -229,6 +237,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* If we have 3 consecutive rtt increases, we are trending upwards (1), or if we have
|
||||
* 3 consecutive rtt decreases, we are trending downwards (-1), else we're stable.
|
||||
*
|
||||
* @return positive/flat/negative trend in round trip time
|
||||
*/
|
||||
public int getRTTTrend() {
|
||||
synchronized (_trend) {
|
||||
@ -255,7 +264,9 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
setRTT(smoothed);
|
||||
}
|
||||
|
||||
/** How long after sending a packet will we wait before resending? */
|
||||
/** How long after sending a packet will we wait before resending?
|
||||
* @return delay for a retransmission in ms
|
||||
*/
|
||||
public int getResendDelay() { return _resendDelay; }
|
||||
public void setResendDelay(int ms) { _resendDelay = ms; }
|
||||
|
||||
@ -265,11 +276,14 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* (_lastSendTime+_sendAckDelay), send an ACK of what
|
||||
* we have received so far.
|
||||
*
|
||||
* @return ACK delay in ms
|
||||
*/
|
||||
public int getSendAckDelay() { return _sendAckDelay; }
|
||||
public void setSendAckDelay(int delayMs) { _sendAckDelay = delayMs; }
|
||||
|
||||
/** What is the largest message we want to send or receive? */
|
||||
/** What is the largest message we want to send or receive?
|
||||
* @return Maximum message size (MTU/MRU)
|
||||
*/
|
||||
public int getMaxMessageSize() { return _maxMessageSize; }
|
||||
public void setMaxMessageSize(int bytes) { _maxMessageSize = bytes; }
|
||||
|
||||
@ -277,13 +291,15 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* how long we want to wait before any data is transferred on the
|
||||
* connection in either direction
|
||||
*
|
||||
* @return how long to wait before any data is transferred in either direction in ms
|
||||
*/
|
||||
public int getChoke() { return _choke; }
|
||||
public void setChoke(int ms) { _choke = ms; }
|
||||
|
||||
/**
|
||||
* What profile do we want to use for this connection?
|
||||
*
|
||||
* TODO: Only bulk is supported so far.
|
||||
* @return the profile of the connection.
|
||||
*/
|
||||
public int getProfile() { return _profile; }
|
||||
public void setProfile(int profile) {
|
||||
@ -295,6 +311,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
/**
|
||||
* How many times will we try to send a message before giving up?
|
||||
*
|
||||
* @return Maximum retrys before failing a sent message.
|
||||
*/
|
||||
public int getMaxResends() { return _maxResends; }
|
||||
public void setMaxResends(int numSends) { _maxResends = numSends; }
|
||||
@ -302,6 +319,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
/**
|
||||
* What period of inactivity qualifies as "too long"?
|
||||
*
|
||||
* @return period of inactivity qualifies as "too long"
|
||||
*/
|
||||
public int getInactivityTimeout() { return _inactivityTimeout; }
|
||||
public void setInactivityTimeout(int timeout) { _inactivityTimeout = timeout; }
|
||||
@ -322,6 +340,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
/**
|
||||
* how much data are we willing to accept in our buffer?
|
||||
*
|
||||
* @return size of the buffer used to accept data
|
||||
*/
|
||||
public int getInboundBufferSize() { return _inboundBufferSize; }
|
||||
public void setInboundBufferSize(int bytes) { _inboundBufferSize = bytes; }
|
||||
@ -331,6 +350,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* of 1/(windowSize*factor). In standard TCP, window sizes are in bytes,
|
||||
* while in I2P, window sizes are in messages, so setting factor=maxMessageSize
|
||||
* mimics TCP, but using a smaller factor helps grow a little more rapidly.
|
||||
* @return window size to grow by to attempt to avoid congestion.
|
||||
*/
|
||||
public int getCongestionAvoidanceGrowthRateFactor() { return _congestionAvoidanceGrowthRateFactor; }
|
||||
public void setCongestionAvoidanceGrowthRateFactor(int factor) { _congestionAvoidanceGrowthRateFactor = factor; }
|
||||
@ -340,10 +360,12 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
* of 1/(factor). In standard TCP, window sizes are in bytes,
|
||||
* while in I2P, window sizes are in messages, so setting factor=maxMessageSize
|
||||
* mimics TCP, but using a smaller factor helps grow a little more rapidly.
|
||||
* @return slow start window size to grow by to attempt to avoid sending many small packets.
|
||||
*/
|
||||
public int getSlowStartGrowthRateFactor() { return _slowStartGrowthRateFactor; }
|
||||
public void setSlowStartGrowthRateFactor(int factor) { _slowStartGrowthRateFactor = factor; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
buf.append("conDelay=").append(_connectDelay);
|
||||
|
@ -16,7 +16,7 @@ public class I2PServerSocketFull implements I2PServerSocket {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @return I2PSocket
|
||||
* @throws net.i2p.I2PException
|
||||
* @throws SocketTimeoutException
|
||||
*/
|
||||
|
@ -119,6 +119,7 @@ public class I2PSocketFull implements I2PSocket {
|
||||
if (c != null)
|
||||
c.disconnectComplete();
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
Connection c = _connection;
|
||||
if (c == null)
|
||||
|
@ -112,7 +112,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @return connected I2PSocket
|
||||
* @throws net.i2p.I2PException
|
||||
* @throws java.net.SocketTimeoutException
|
||||
*/
|
||||
@ -141,7 +141,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
*
|
||||
* @param peer
|
||||
* @param timeoutMs
|
||||
* @return
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
public boolean ping(Destination peer, long timeoutMs) {
|
||||
return _connectionManager.ping(peer, timeoutMs);
|
||||
@ -246,6 +246,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
/**
|
||||
* Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
|
||||
*
|
||||
* @return set of currently connected I2PSockets
|
||||
*/
|
||||
public Set listSockets() {
|
||||
Set connections = _connectionManager.listConnections();
|
||||
|
@ -70,6 +70,7 @@ public class MessageHandler implements I2PSessionListener {
|
||||
/**
|
||||
* Notify the client that the session has been terminated
|
||||
*
|
||||
* @param session that has been terminated
|
||||
*/
|
||||
public void disconnected(I2PSession session) {
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
@ -90,6 +91,9 @@ public class MessageHandler implements I2PSessionListener {
|
||||
/**
|
||||
* Notify the client that some error occurred
|
||||
*
|
||||
* @param session of the client
|
||||
* @param message to send to the client about the error
|
||||
* @param error the actual error
|
||||
*/
|
||||
public void errorOccurred(I2PSession session, String message, Throwable error) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
|
@ -73,7 +73,9 @@ public class MessageInputStream extends InputStream {
|
||||
_cache = ByteCache.getInstance(128, Packet.MAX_PAYLOAD_SIZE);
|
||||
}
|
||||
|
||||
/** What is the highest block ID we've completely received through? */
|
||||
/** What is the highest block ID we've completely received through?
|
||||
* @return highest data block ID completely received
|
||||
*/
|
||||
public long getHighestReadyBockId() {
|
||||
// not synchronized as it doesnt hurt to read a too-low value
|
||||
return _highestReadyBlockId;
|
||||
@ -89,6 +91,7 @@ public class MessageInputStream extends InputStream {
|
||||
* past the highest ready ID and below the highest received message
|
||||
* ID. This may return null if there are no such IDs.
|
||||
*
|
||||
* @return array of message ID holes, or null if none
|
||||
*/
|
||||
public long[] getNacks() {
|
||||
synchronized (_dataLock) {
|
||||
@ -128,6 +131,7 @@ public class MessageInputStream extends InputStream {
|
||||
* Ascending list of block IDs greater than the highest
|
||||
* ready block ID, or null if there aren't any.
|
||||
*
|
||||
* @return block IDs greater than the highest ready block ID, or null if there aren't any.
|
||||
*/
|
||||
public long[] getOutOfOrderBlocks() {
|
||||
long blocks[] = null;
|
||||
@ -146,7 +150,9 @@ public class MessageInputStream extends InputStream {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/** how many blocks have we received that we still have holes before? */
|
||||
/** how many blocks have we received that we still have holes before?
|
||||
* @return Count of blocks received that still have holes
|
||||
*/
|
||||
public int getOutOfOrderBlockCount() {
|
||||
synchronized (_dataLock) {
|
||||
return _notYetReadyBlocks.size();
|
||||
@ -156,6 +162,7 @@ public class MessageInputStream extends InputStream {
|
||||
/**
|
||||
* how long a read() call should block (if less than 0, block indefinitely,
|
||||
* but if it is 0, do not block at all)
|
||||
* @return how long read calls should block, 0 or less indefinitely block
|
||||
*/
|
||||
public int getReadTimeout() { return _readTimeout; }
|
||||
public void setReadTimeout(int timeout) {
|
||||
@ -203,6 +210,8 @@ public class MessageInputStream extends InputStream {
|
||||
* A new message has arrived - toss it on the appropriate queue (moving
|
||||
* previously pending messages to the ready queue if it fills the gap, etc).
|
||||
*
|
||||
* @param messageId ID of the message
|
||||
* @param payload message payload
|
||||
* @return true if this is a new packet, false if it is a dup
|
||||
*/
|
||||
public boolean messageReceived(long messageId, ByteArray payload) {
|
||||
@ -260,10 +269,12 @@ public class MessageInputStream extends InputStream {
|
||||
return _oneByte[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte target[]) throws IOException {
|
||||
return read(target, 0, target.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte target[], int offset, int length) throws IOException {
|
||||
if (_locallyClosed) throw new IOException("Already locally closed");
|
||||
throwAnyError();
|
||||
@ -360,6 +371,7 @@ public class MessageInputStream extends InputStream {
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
if (_locallyClosed) throw new IOException("Already closed, you wanker");
|
||||
throwAnyError();
|
||||
@ -383,6 +395,7 @@ public class MessageInputStream extends InputStream {
|
||||
* How many bytes are queued up for reading (or sitting in the out-of-order
|
||||
* buffer)?
|
||||
*
|
||||
* @return Count of bytes waiting to be read
|
||||
*/
|
||||
public int getTotalQueuedSize() {
|
||||
synchronized (_dataLock) {
|
||||
@ -418,6 +431,7 @@ public class MessageInputStream extends InputStream {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
synchronized (_dataLock) {
|
||||
//while (_readyDataBlocks.size() > 0)
|
||||
|
@ -77,10 +77,12 @@ public class MessageOutputStream extends OutputStream {
|
||||
public int getWriteTimeout() { return _writeTimeout; }
|
||||
public void setBufferSize(int size) { _nextBufferSize = size; }
|
||||
|
||||
@Override
|
||||
public void write(byte b[]) throws IOException {
|
||||
write(b, 0, b.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
if (_closed) throw new IOException("Already closed");
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
@ -159,7 +161,7 @@ public class MessageOutputStream extends OutputStream {
|
||||
int periods = (int)Math.floor((now - _sendPeriodBeginTime) / 1000d);
|
||||
if (periods > 0) {
|
||||
// first term decays on slow transmission
|
||||
_sendBps = (int)(((float)0.9f*((float)_sendBps/(float)periods)) + ((float)0.1f*((float)_sendPeriodBytes/(float)periods)));
|
||||
_sendBps = (int)((0.9f*((float)_sendBps/(float)periods)) + (0.1f*((float)_sendPeriodBytes/(float)periods)));
|
||||
_sendPeriodBytes = len;
|
||||
_sendPeriodBeginTime = now;
|
||||
_context.statManager().addRateData("stream.sendBps", _sendBps, 0);
|
||||
@ -255,9 +257,12 @@ public class MessageOutputStream extends OutputStream {
|
||||
* delivered.
|
||||
*
|
||||
* @throws IOException if the write fails
|
||||
* @throws InterruptedIOException if the write times out
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
/* @throws InterruptedIOException if the write times out
|
||||
* Documented here, but doesn't belong in the javadoc.
|
||||
*/
|
||||
long begin = _context.clock().now();
|
||||
WriteStatus ws = null;
|
||||
synchronized (_dataLock) {
|
||||
|
@ -149,7 +149,9 @@ public class Packet {
|
||||
public Packet() { }
|
||||
|
||||
private boolean _sendStreamIdSet = false;
|
||||
/** what stream do we send data to the peer on? */
|
||||
/** what stream do we send data to the peer on?
|
||||
* @return stream ID we use to send data
|
||||
*/
|
||||
public long getSendStreamId() { return _sendStreamId; }
|
||||
public void setSendStreamId(long id) {
|
||||
if ( (_sendStreamIdSet) && (_sendStreamId > 0) )
|
||||
@ -162,6 +164,7 @@ public class Packet {
|
||||
/**
|
||||
* stream the replies should be sent on. this should be 0 if the
|
||||
* connection is still being built.
|
||||
* @return stream ID we use to get data, zero if the connection is still being built.
|
||||
*/
|
||||
public long getReceiveStreamId() { return _receiveStreamId; }
|
||||
public void setReceiveStreamId(long id) {
|
||||
@ -171,7 +174,9 @@ public class Packet {
|
||||
_receiveStreamId = id;
|
||||
}
|
||||
|
||||
/** 0-indexed sequence number for this Packet in the sendStream */
|
||||
/** 0-indexed sequence number for this Packet in the sendStream
|
||||
* @return 0-indexed sequence number for current Packet in current sendStream
|
||||
*/
|
||||
public long getSequenceNum() { return _sequenceNum; }
|
||||
public void setSequenceNum(long num) { _sequenceNum = num; }
|
||||
|
||||
@ -181,6 +186,7 @@ public class Packet {
|
||||
* connection packet (where receiveStreamId is the unknown id) or
|
||||
* if FLAG_NO_ACK is set.
|
||||
*
|
||||
* @return The highest packet sequence number received on receiveStreamId
|
||||
*/
|
||||
public long getAckThrough() {
|
||||
if (isFlagSet(FLAG_NO_ACK))
|
||||
@ -198,6 +204,7 @@ public class Packet {
|
||||
* List of packet sequence numbers below the getAckThrough() value
|
||||
* have not been received. this may be null.
|
||||
*
|
||||
* @return List of packet sequence numbers not ACKed, or null if there are none.
|
||||
*/
|
||||
public long[] getNacks() { return _nacks; }
|
||||
public void setNacks(long nacks[]) { _nacks = nacks; }
|
||||
@ -207,13 +214,16 @@ public class Packet {
|
||||
* resending this packet (if it hasn't yet been ACKed). The
|
||||
* value is seconds since the packet was created.
|
||||
*
|
||||
* @return Delay before resending a packet in seconds.
|
||||
*/
|
||||
public int getResendDelay() { return _resendDelay; }
|
||||
public void setResendDelay(int numSeconds) { _resendDelay = numSeconds; }
|
||||
|
||||
public static final int MAX_PAYLOAD_SIZE = 32*1024;
|
||||
|
||||
/** get the actual payload of the message. may be null */
|
||||
/** get the actual payload of the message. may be null
|
||||
* @return the payload of the message, null if none.
|
||||
*/
|
||||
public ByteArray getPayload() { return _payload; }
|
||||
public void setPayload(ByteArray payload) {
|
||||
_payload = payload;
|
||||
@ -232,7 +242,10 @@ public class Packet {
|
||||
return _payload;
|
||||
}
|
||||
|
||||
/** is a particular flag set on this packet? */
|
||||
/** is a particular flag set on this packet?
|
||||
* @param flag bitmask of any flag(s)
|
||||
* @return true if set, false if not.
|
||||
*/
|
||||
public boolean isFlagSet(int flag) { return 0 != (_flags & flag); }
|
||||
public void setFlag(int flag) { _flags |= flag; }
|
||||
public void setFlag(int flag, boolean set) {
|
||||
@ -243,14 +256,18 @@ public class Packet {
|
||||
}
|
||||
public void setFlags(int flags) { _flags = flags; }
|
||||
|
||||
/** the signature on the packet (only included if the flag for it is set) */
|
||||
/** the signature on the packet (only included if the flag for it is set)
|
||||
* @return signature on the packet if the flag for signatures is set
|
||||
*/
|
||||
public Signature getOptionalSignature() { return _optionSignature; }
|
||||
public void setOptionalSignature(Signature sig) {
|
||||
setFlag(FLAG_SIGNATURE_INCLUDED, sig != null);
|
||||
_optionSignature = sig;
|
||||
}
|
||||
|
||||
/** the sender of the packet (only included if the flag for it is set) */
|
||||
/** the sender of the packet (only included if the flag for it is set)
|
||||
* @return the sending Destination
|
||||
*/
|
||||
public Destination getOptionalFrom() { return _optionFrom; }
|
||||
public void setOptionalFrom(Destination from) {
|
||||
setFlag(FLAG_FROM_INCLUDED, from != null);
|
||||
@ -262,6 +279,7 @@ public class Packet {
|
||||
* How many milliseconds the sender of this packet wants the recipient
|
||||
* to wait before sending any more data (only valid if the flag for it is
|
||||
* set)
|
||||
* @return How long the sender wants the recipient to wait before sending any more data in ms.
|
||||
*/
|
||||
public int getOptionalDelay() { return _optionDelay; }
|
||||
public void setOptionalDelay(int delayMs) {
|
||||
@ -276,6 +294,7 @@ public class Packet {
|
||||
/**
|
||||
* What is the largest payload the sender of this packet wants to receive?
|
||||
*
|
||||
* @return Maximum payload size sender can receive (MRU)
|
||||
*/
|
||||
public int getOptionalMaxSize() { return _optionMaxSize; }
|
||||
public void setOptionalMaxSize(int numBytes) {
|
||||
@ -287,6 +306,9 @@ public class Packet {
|
||||
* Write the packet to the buffer (starting at the offset) and return
|
||||
* the number of bytes written.
|
||||
*
|
||||
* @param buffer bytes to write to a destination
|
||||
* @param offset starting point in the buffer to send
|
||||
* @return Count actually written
|
||||
* @throws IllegalStateException if there is data missing or otherwise b0rked
|
||||
*/
|
||||
public int writePacket(byte buffer[], int offset) throws IllegalStateException {
|
||||
@ -370,6 +392,8 @@ public class Packet {
|
||||
|
||||
/**
|
||||
* how large would this packet be if we wrote it
|
||||
* @return How large the current packet would be
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
public int writtenSize() throws IllegalStateException {
|
||||
int size = 0;
|
||||
@ -497,7 +521,10 @@ public class Packet {
|
||||
/**
|
||||
* Determine whether the signature on the data is valid.
|
||||
*
|
||||
* @return true if the signature exists and validates against the data,
|
||||
* @param ctx Application context
|
||||
* @param from the Destination the data came from
|
||||
* @param buffer data to validate with signature
|
||||
* @return true if the signature exists and validates against the data,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean verifySignature(I2PAppContext ctx, Destination from, byte buffer[]) {
|
||||
@ -530,6 +557,11 @@ public class Packet {
|
||||
* Sign and write the packet to the buffer (starting at the offset) and return
|
||||
* the number of bytes written.
|
||||
*
|
||||
* @param buffer data to be written
|
||||
* @param offset starting point in the buffer
|
||||
* @param ctx Application Context
|
||||
* @param key signing key
|
||||
* @return Count of bytes written
|
||||
* @throws IllegalStateException if there is data missing or otherwise b0rked
|
||||
*/
|
||||
public int writeSignedPacket(byte buffer[], int offset, I2PAppContext ctx, SigningPrivateKey key) throws IllegalStateException {
|
||||
@ -560,6 +592,7 @@ public class Packet {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer str = formatAsString();
|
||||
return str.toString();
|
||||
|
@ -107,7 +107,9 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
|
||||
}
|
||||
public SimpleTimer.TimedEvent getResendEvent() { return _resendEvent; }
|
||||
|
||||
/** how long after packet creation was it acked? */
|
||||
/** how long after packet creation was it acked?
|
||||
* @return how long after packet creation the packet was ACKed in ms
|
||||
*/
|
||||
public int getAckTime() {
|
||||
if (_ackOn <= 0)
|
||||
return -1;
|
||||
@ -130,6 +132,7 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
|
||||
|
||||
public void setResendPacketEvent(SimpleTimer.TimedEvent evt) { _resendEvent = evt; }
|
||||
|
||||
@Override
|
||||
public StringBuffer formatAsString() {
|
||||
StringBuffer buf = super.formatAsString();
|
||||
|
||||
|
Reference in New Issue
Block a user