Moved the messaging protocol one step closer to BSP.

This breaks backward compatibility for the wire protocol and messages
stored in the database. The database schema version has been
incremented.
This commit is contained in:
akwizgran
2015-05-01 16:58:49 +01:00
parent ffcc8b6b38
commit 32c9ce50d9
33 changed files with 732 additions and 750 deletions

View File

@@ -1,18 +1,19 @@
package org.briarproject.api.messaging;
import static org.briarproject.api.transport.TransportConstants.MIN_STREAM_LENGTH;
public interface MessagingConstants {
/**
* The maximum length of a serialised packet in bytes. To allow for future
* changes in the protocol, this is smaller than the minimum stream length
* minus the maximum encryption and authentication overhead.
*/
int MAX_PACKET_LENGTH = MIN_STREAM_LENGTH / 2;
/** The current version of the messaging protocol. */
byte PROTOCOL_VERSION = 0;
/** The length of the packet header in bytes. */
int HEADER_LENGTH = 4;
/** The maximum length of the packet payload in bytes. */
int MAX_PAYLOAD_LENGTH = 32 * 1024; // 32 KiB
/** The maximum number of public groups a user may subscribe to. */
int MAX_SUBSCRIPTIONS = 3000;
int MAX_SUBSCRIPTIONS = 300;
/** The maximum length of a group's name in UTF-8 bytes. */
int MAX_GROUP_NAME_LENGTH = 50;
@@ -22,10 +23,10 @@ public interface MessagingConstants {
/**
* The maximum length of a message body in bytes. To allow for future
* changes in the protocol, this is smaller than the maximum packet length
* changes in the protocol, this is smaller than the maximum payload length
* even when all the message's other fields have their maximum lengths.
*/
int MAX_BODY_LENGTH = MAX_PACKET_LENGTH - 1024;
int MAX_BODY_LENGTH = MAX_PAYLOAD_LENGTH - 1024;
/** The maximum length of a message's content type in UTF-8 bytes. */
int MAX_CONTENT_TYPE_LENGTH = 50;

View File

@@ -0,0 +1,16 @@
package org.briarproject.api.messaging;
/** Packet types for the messaging protocol. */
public interface PacketTypes {
byte ACK = 0;
byte MESSAGE = 1;
byte OFFER = 2;
byte REQUEST = 3;
byte RETENTION_ACK = 4;
byte RETENTION_UPDATE = 5;
byte SUBSCRIPTION_ACK = 6;
byte SUBSCRIPTION_UPDATE = 7;
byte TRANSPORT_ACK = 8;
byte TRANSPORT_UPDATE = 9;
}

View File

@@ -1,18 +0,0 @@
package org.briarproject.api.messaging;
/** Struct identifiers for encoding and decoding protocol objects. */
public interface Types {
int AUTHOR = 0;
int GROUP = 1;
int ACK = 2;
int MESSAGE = 3;
int OFFER = 4;
int REQUEST = 5;
int RETENTION_ACK = 6;
int RETENTION_UPDATE = 7;
int SUBSCRIPTION_ACK = 8;
int SUBSCRIPTION_UPDATE = 9;
int TRANSPORT_ACK = 10;
int TRANSPORT_UPDATE = 11;
}