mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Changed maximum packet and message sizes in preparation for new
transport format.
This commit is contained in:
@@ -5,12 +5,6 @@ import java.util.Collection;
|
||||
/** A packet acknowledging receipt of one or more batches. */
|
||||
public interface Ack {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialised ack, excluding encryption and
|
||||
* authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the IDs of the acknowledged batches. */
|
||||
Collection<BatchId> getBatchIds();
|
||||
}
|
||||
|
||||
@@ -5,12 +5,15 @@ import net.sf.briar.api.serial.Writable;
|
||||
/** A pseudonymous author of messages. */
|
||||
public interface Author extends Writable {
|
||||
|
||||
/** The maximum length of an author's name, in UTF-8 bytes. */
|
||||
/** The maximum length of an author's name in UTF-8 bytes. */
|
||||
static final int MAX_NAME_LENGTH = 50;
|
||||
|
||||
/** The maximum length of an author's public key, in bytes. */
|
||||
/** The maximum length of an author's public key in bytes. */
|
||||
static final int MAX_PUBLIC_KEY_LENGTH = 100;
|
||||
|
||||
/** The maximum length of a serialised author in bytes. */
|
||||
static final int MAX_LENGTH = MAX_NAME_LENGTH + MAX_PUBLIC_KEY_LENGTH + 5;
|
||||
|
||||
/** Returns the author's unique identifier. */
|
||||
AuthorId getId();
|
||||
|
||||
|
||||
@@ -5,12 +5,6 @@ import java.util.Collection;
|
||||
/** A packet containing messages. */
|
||||
public interface Batch {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialised batch, excluding encryption and
|
||||
* authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the batch's unique identifier. */
|
||||
BatchId getId();
|
||||
|
||||
|
||||
@@ -5,12 +5,15 @@ import net.sf.briar.api.serial.Writable;
|
||||
/** A group to which users may subscribe. */
|
||||
public interface Group extends Writable {
|
||||
|
||||
/** The maximum length of a group's name, in UTF-8 bytes. */
|
||||
/** The maximum length of a group's name in UTF-8 bytes. */
|
||||
static final int MAX_NAME_LENGTH = 50;
|
||||
|
||||
/** The maximum length of a group's public key, in bytes. */
|
||||
/** The maximum length of a group's public key in bytes. */
|
||||
static final int MAX_PUBLIC_KEY_LENGTH = 100;
|
||||
|
||||
/** The maximum length of a serialised group in bytes. */
|
||||
static final int MAX_LENGTH = MAX_NAME_LENGTH + MAX_PUBLIC_KEY_LENGTH + 5;
|
||||
|
||||
/** Returns the group's unique identifier. */
|
||||
GroupId getId();
|
||||
|
||||
|
||||
@@ -2,12 +2,23 @@ package net.sf.briar.api.protocol;
|
||||
|
||||
public interface Message {
|
||||
|
||||
/** The maximum size of a serialised message, in bytes. */
|
||||
static final int MAX_SIZE = (1024 * 1024) - 200;
|
||||
/**
|
||||
* The maximum length of a serialised message in bytes. To allow for future
|
||||
* changes in the batch format, this is smaller than the amount of data
|
||||
* that can fit in a batch using the current format.
|
||||
*/
|
||||
static final int MAX_LENGTH = ProtocolConstants.MAX_PACKET_LENGTH - 1024;
|
||||
|
||||
/** The maximum size of a signature, in bytes. */
|
||||
/** The maximum length of a signature in bytes. */
|
||||
static final int MAX_SIGNATURE_LENGTH = 100;
|
||||
|
||||
/**
|
||||
* The maximum length of a message body in bytes. To allow for future
|
||||
* changes in the message format, this is smaller than the amount of data
|
||||
* that can fit in a message using the current format.
|
||||
*/
|
||||
static final int MAX_BODY_LENGTH = MAX_LENGTH - 1024;
|
||||
|
||||
/** Returns the message's unique identifier. */
|
||||
MessageId getId();
|
||||
|
||||
|
||||
@@ -5,12 +5,6 @@ import java.util.Collection;
|
||||
/** A packet offering the recipient some messages. */
|
||||
public interface Offer {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialised offer, excluding encryption and
|
||||
* authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the offer's unique identifier. */
|
||||
OfferId getId();
|
||||
|
||||
|
||||
14
api/net/sf/briar/api/protocol/ProtocolConstants.java
Normal file
14
api/net/sf/briar/api/protocol/ProtocolConstants.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
import net.sf.briar.api.transport.TransportConstants;
|
||||
|
||||
public interface ProtocolConstants {
|
||||
|
||||
/**
|
||||
* The maximum length of a serialised packet in bytes. To allow for future
|
||||
* changes in the frame format, this is smaller than the amount of data
|
||||
* that can fit in a frame using the current format.
|
||||
*/
|
||||
static final int MAX_PACKET_LENGTH =
|
||||
TransportConstants.MAX_FRAME_LENGTH - 1024;
|
||||
}
|
||||
@@ -5,12 +5,6 @@ import java.util.BitSet;
|
||||
/** A packet requesting some or all of the messages from an offer. */
|
||||
public interface Request {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialised request, exlcuding encryption and
|
||||
* authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/**
|
||||
* Returns the unique identifier of the offer to which this request
|
||||
* responds.
|
||||
|
||||
@@ -5,12 +5,6 @@ import java.util.Map;
|
||||
/** A packet updating the sender's subscriptions. */
|
||||
public interface SubscriptionUpdate {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialized subscription update, excluding
|
||||
* encryption and authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the subscriptions contained in the update. */
|
||||
Map<Group, Long> getSubscriptions();
|
||||
|
||||
|
||||
@@ -5,12 +5,6 @@ import java.util.Map;
|
||||
/** A packet updating the sender's transport properties. */
|
||||
public interface TransportUpdate {
|
||||
|
||||
/**
|
||||
* The maximum size of a serialised transport update, excluding
|
||||
* encryption and authentication.
|
||||
*/
|
||||
static final int MAX_SIZE = (1024 * 1024) - 100;
|
||||
|
||||
/** Returns the transport properties contained in the update. */
|
||||
Map<String, Map<String, String>> getTransports();
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import net.sf.briar.api.serial.Writable;
|
||||
|
||||
public abstract class UniqueId implements Writable {
|
||||
|
||||
/** The length of a unique identifier in bytes. */
|
||||
public static final int LENGTH = 32;
|
||||
public static final int SERIALISED_LENGTH = LENGTH + 3;
|
||||
|
||||
protected final byte[] id;
|
||||
|
||||
|
||||
22
api/net/sf/briar/api/transport/TransportConstants.java
Normal file
22
api/net/sf/briar/api/transport/TransportConstants.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.sf.briar.api.transport;
|
||||
|
||||
public interface TransportConstants {
|
||||
|
||||
/**
|
||||
* The maximum length of a frame in bytes, including the header and footer.
|
||||
*/
|
||||
static final int MAX_FRAME_LENGTH = 65536; // 2^16
|
||||
|
||||
/** The length in bytes of the tag that uniquely identifies a connection. */
|
||||
static final int TAG_LENGTH = 16;
|
||||
|
||||
/**
|
||||
* The maximum value that can be represented as an unsigned 16-bit integer.
|
||||
*/
|
||||
static final int MAX_16_BIT_UNSIGNED = 65535; // 2^16 - 1
|
||||
|
||||
/**
|
||||
* The maximum value that can be represented as an unsigned 32-bit integer.
|
||||
*/
|
||||
static final long MAX_32_BIT_UNSIGNED = 4294967295L; // 2^32 - 1
|
||||
}
|
||||
Reference in New Issue
Block a user