Renamed a load of things from 'connection' to 'stream'.

This commit is contained in:
akwizgran
2014-10-08 16:18:33 +01:00
parent 39f79b55ef
commit b24f153704
84 changed files with 671 additions and 671 deletions

View File

@@ -8,13 +8,13 @@ import org.briarproject.api.plugins.simplex.SimplexTransportWriter;
public interface ConnectionDispatcher {
void dispatchReader(TransportId t, SimplexTransportReader r);
void dispatchWriter(ContactId c, TransportId t,
SimplexTransportWriter w);
void dispatchIncomingConnection(TransportId t, SimplexTransportReader r);
void dispatchIncomingConnection(TransportId t, DuplexTransportConnection d);
void dispatchOutgoingConnection(ContactId c, TransportId t,
SimplexTransportWriter w);
void dispatchOutgoingConnection(ContactId c, TransportId t,
DuplexTransportConnection d);
}

View File

@@ -1,14 +0,0 @@
package org.briarproject.api.transport;
import java.io.InputStream;
public interface ConnectionReaderFactory {
/** Creates a connection reader for one side of a connection. */
ConnectionReader createConnectionReader(InputStream in, int maxFrameLength,
ConnectionContext ctx, boolean incoming, boolean initiator);
/** Creates a connection reader for one side of an invitation connection. */
ConnectionReader createInvitationConnectionReader(InputStream in,
int maxFrameLength, byte[] secret, boolean alice);
}

View File

@@ -1,29 +0,0 @@
package org.briarproject.api.transport;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportId;
import org.briarproject.api.db.DbException;
/**
* Maintains the connection reordering windows and decides whether incoming
* connections should be accepted or rejected.
*/
public interface ConnectionRecogniser {
/**
* Returns the context for the given connection if the connection was
* expected, or null if the connection was not expected.
*/
ConnectionContext acceptConnection(TransportId t, byte[] tag)
throws DbException;
void addSecret(TemporarySecret s);
void removeSecret(ContactId c, TransportId t, long period);
void removeSecrets(ContactId c);
void removeSecrets(TransportId t);
void removeSecrets();
}

View File

@@ -1,15 +0,0 @@
package org.briarproject.api.transport;
import java.io.OutputStream;
public interface ConnectionWriterFactory {
/** Creates a connection writer for one side of a connection. */
ConnectionWriter createConnectionWriter(OutputStream out,
int maxFrameLength, long capacity, ConnectionContext ctx,
boolean incoming, boolean initiator);
/** Creates a connection writer for one side of an invitation connection. */
ConnectionWriter createInvitationConnectionWriter(OutputStream out,
int maxFrameLength, byte[] secret, boolean alice);
}

View File

@@ -3,20 +3,20 @@ package org.briarproject.api.transport;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportId;
public class ConnectionContext {
public class StreamContext {
private final ContactId contactId;
private final TransportId transportId;
private final byte[] secret;
private final long connection;
private final long streamNumber;
private final boolean alice;
public ConnectionContext(ContactId contactId, TransportId transportId,
byte[] secret, long connection, boolean alice) {
public StreamContext(ContactId contactId, TransportId transportId,
byte[] secret, long streamNumber, boolean alice) {
this.contactId = contactId;
this.transportId = transportId;
this.secret = secret;
this.connection = connection;
this.streamNumber = streamNumber;
this.alice = alice;
}
@@ -32,8 +32,8 @@ public class ConnectionContext {
return secret;
}
public long getConnectionNumber() {
return connection;
public long getStreamNumber() {
return streamNumber;
}
public boolean getAlice() {

View File

@@ -2,8 +2,8 @@ package org.briarproject.api.transport;
import java.io.InputStream;
/** Decrypts and authenticates data received over a connection. */
public interface ConnectionReader {
/** Decrypts and authenticates data received over an underlying transport. */
public interface StreamReader {
/**
* Returns an input stream from which the decrypted, authenticated data can

View File

@@ -0,0 +1,14 @@
package org.briarproject.api.transport;
import java.io.InputStream;
public interface StreamReaderFactory {
/** Creates a {@link StreamReader} for a transport connection. */
StreamReader createStreamReader(InputStream in, int maxFrameLength,
StreamContext ctx, boolean incoming, boolean initiator);
/** Creates a {@link StreamReader} for an invitation connection. */
StreamReader createInvitationStreamReader(InputStream in,
int maxFrameLength, byte[] secret, boolean alice);
}

View File

@@ -2,8 +2,8 @@ package org.briarproject.api.transport;
import java.io.OutputStream;
/** Encrypts and authenticates data to be sent over a connection. */
public interface ConnectionWriter {
/** Encrypts and authenticates data to be sent over an underlying transport. */
public interface StreamWriter {
/**
* Returns an output stream to which unencrypted, unauthenticated data can
@@ -11,6 +11,9 @@ public interface ConnectionWriter {
*/
OutputStream getOutputStream();
/** Returns the maximum number of bytes that can be written. */
/**
* Returns the maximum number of bytes that can be written to the output
* stream.
*/
long getRemainingCapacity();
}

View File

@@ -0,0 +1,15 @@
package org.briarproject.api.transport;
import java.io.OutputStream;
public interface StreamWriterFactory {
/** Creates a {@link StreamWriter} for a transport connection. */
StreamWriter createStreamWriter(OutputStream out, int maxFrameLength,
long capacity, StreamContext ctx, boolean incoming,
boolean initiator);
/** Creates a {@link StreamWriter} for an invitation connection. */
StreamWriter createInvitationStreamWriter(OutputStream out,
int maxFrameLength, byte[] secret, boolean alice);
}

View File

@@ -0,0 +1,25 @@
package org.briarproject.api.transport;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportId;
import org.briarproject.api.db.DbException;
/** Maintains the table of expected tags for recognising incoming streams. */
public interface TagRecogniser {
/**
* Returns a {@link StreamContext} for reading from the stream with the
* given tag if the tag was expected, or null if the tag was unexpected.
*/
StreamContext recogniseTag(TransportId t, byte[] tag) throws DbException;
void addSecret(TemporarySecret s);
void removeSecret(ContactId c, TransportId t, long period);
void removeSecrets(ContactId c);
void removeSecrets(TransportId t);
void removeSecrets();
}

View File

@@ -1,6 +1,7 @@
package org.briarproject.api.transport;
import static org.briarproject.api.transport.TransportConstants.CONNECTION_WINDOW_SIZE;
import static org.briarproject.api.transport.TransportConstants.REORDERING_WINDOW_SIZE;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportId;
@@ -9,7 +10,7 @@ public class TemporarySecret extends Endpoint {
private final long period, outgoing, centre;
private final byte[] secret, bitmap;
/** Creates a temporary secret with the given connection window. */
/** Creates a temporary secret with the given reordering window. */
public TemporarySecret(ContactId contactId, TransportId transportId,
long epoch, boolean alice, long period, byte[] secret,
long outgoing, long centre, byte[] bitmap) {
@@ -21,11 +22,11 @@ public class TemporarySecret extends Endpoint {
this.bitmap = bitmap;
}
/** Creates a temporary secret with a new connection window. */
/** Creates a temporary secret with a new reordering window. */
public TemporarySecret(ContactId contactId, TransportId transportId,
long epoch, boolean alice, long period, byte[] secret) {
this(contactId, transportId, epoch, alice, period, secret, 0, 0,
new byte[CONNECTION_WINDOW_SIZE / 8]);
new byte[REORDERING_WINDOW_SIZE / 8]);
}
/** Creates a temporary secret derived from the given endpoint. */
@@ -42,7 +43,7 @@ public class TemporarySecret extends Endpoint {
return secret;
}
public long getOutgoingConnectionCounter() {
public long getOutgoingStreamCounter() {
return outgoing;
}

View File

@@ -2,7 +2,7 @@ package org.briarproject.api.transport;
public interface TransportConstants {
/** The length of the connection tag in bytes. */
/** The length of the pseudo-random tag in bytes. */
int TAG_LENGTH = 16;
/** The maximum length of a frame in bytes, including the header and MAC. */
@@ -21,15 +21,15 @@ public interface TransportConstants {
int MAC_LENGTH = 16;
/**
* The minimum connection length in bytes that all transport plugins must
* support. Connections may be shorter than this length, but all transport
* plugins must support connections of at least this length.
* The minimum stream length in bytes that all transport plugins must
* support. Streams may be shorter than this length, but all transport
* plugins must support streams of at least this length.
*/
int MIN_CONNECTION_LENGTH = 1024 * 1024; // 2^20, 1 MiB
int MIN_STREAM_LENGTH = 1024 * 1024; // 2^20, 1 MiB
/** The maximum difference between two communicating devices' clocks. */
int MAX_CLOCK_DIFFERENCE = 60 * 60 * 1000; // 1 hour
/** The size of the connection reordering window. */
int CONNECTION_WINDOW_SIZE = 32;
/** The size of the reordering window. */
int REORDERING_WINDOW_SIZE = 32;
}