mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Pass segments rather than frames to/from segmented plugins.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
16
api/net/sf/briar/api/plugins/Segment.java
Normal file
16
api/net/sf/briar/api/plugins/Segment.java
Normal 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);
|
||||
}
|
||||
9
api/net/sf/briar/api/plugins/SegmentSink.java
Normal file
9
api/net/sf/briar/api/plugins/SegmentSink.java
Normal 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;
|
||||
}
|
||||
12
api/net/sf/briar/api/plugins/SegmentSource.java
Normal file
12
api/net/sf/briar/api/plugins/SegmentSource.java
Normal 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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user