Pass segments rather than frames to/from segmented plugins.

This commit is contained in:
akwizgran
2012-01-13 15:05:42 +00:00
parent d0e402062a
commit ac136d3732
23 changed files with 155 additions and 61 deletions

View File

@@ -1,9 +0,0 @@
package net.sf.briar.api.plugins;
import java.io.IOException;
public interface FrameSink {
/** Writes the given frame. */
void writeFrame(byte[] b, int len) throws IOException;
}

View File

@@ -1,12 +0,0 @@
package net.sf.briar.api.plugins;
import java.io.IOException;
public interface FrameSource {
/**
* Reads a frame into the given buffer and returns its length, or -1 if no
* more frames can be read.
*/
int readFrame(byte[] b) throws IOException;
}

View File

@@ -0,0 +1,16 @@
package net.sf.briar.api.plugins;
public interface Segment {
void clear();
byte[] getBuffer();
int getLength();
long getTransmissionNumber();
void setLength(int length);
void setTransmissionNumber(int transmission);
}

View File

@@ -0,0 +1,9 @@
package net.sf.briar.api.plugins;
import java.io.IOException;
public interface SegmentSink {
/** Writes the given segment. */
void writeSegment(Segment s) throws IOException;
}

View File

@@ -0,0 +1,12 @@
package net.sf.briar.api.plugins;
import java.io.IOException;
public interface SegmentSource {
/**
* Attempts to read a segment into the given buffer and returns true if a
* segment was read, or false if no more segments can be read.
*/
boolean readSegment(Segment s) throws IOException;
}

View File

@@ -1,15 +1,15 @@
package net.sf.briar.api.plugins.duplex;
import net.sf.briar.api.plugins.FrameSink;
import net.sf.briar.api.plugins.FrameSource;
import net.sf.briar.api.plugins.SegmentSink;
import net.sf.briar.api.plugins.SegmentSource;
/**
* An interface for reading and writing data over a duplex segmented transport.
* The connection is not responsible for encrypting/decrypting or authenticating
* the data.
*/
public interface DuplexSegmentedTransportConnection extends FrameSource,
FrameSink {
public interface DuplexSegmentedTransportConnection extends SegmentSource,
SegmentSink {
/** Returns the maximum length of a segment in bytes. */
int getMaximumSegmentLength();

View File

@@ -1,13 +1,13 @@
package net.sf.briar.api.plugins.simplex;
import net.sf.briar.api.plugins.FrameSource;
import net.sf.briar.api.plugins.SegmentSource;
/**
* An interface for reading data from a simplex segmented transport. The reader
* is not responsible for decrypting or authenticating the data before
* returning it.
*/
public interface SimplexSegmentedTransportReader extends FrameSource {
public interface SimplexSegmentedTransportReader extends SegmentSource {
/**
* Closes the reader and disposes of any associated resources. The first

View File

@@ -1,12 +1,12 @@
package net.sf.briar.api.plugins.simplex;
import net.sf.briar.api.plugins.FrameSink;
import net.sf.briar.api.plugins.SegmentSink;
/**
* An interface for writing data to a simplex segmented transport. The writer is
* not responsible for authenticating or encrypting the data before writing it.
*/
public interface SimplexSegmentedTransportWriter extends FrameSink {
public interface SimplexSegmentedTransportWriter extends SegmentSink {
/** Returns the capacity of the transport in bytes. */
long getCapacity();