Requirements
The Mailbox protocol assumes that all messages are encrypted and authenticated by an underlying protocol (BTP).
Messages
Mailbox messages are implemented as BDF lists with the following format:
[TYPE, MESSAGE_ID, BODY]
-
TYPE: [BDF long] An integer identifying the Message Type.
-
MESSAGE_ID: [BDF long] An integer which must be unique (for active requests).
-
BODY: [BDF list] A list which is formatted depending on the message type
Responses
Depending on the TYPE, a Request may have a response.
-
MESSAGE_ID: The Id must match the corresponding request's Id.
-
BODY: Formatted depending on the request.
Requests
OFFER
An OFFER request indicates that the connected peer wants to send a chunked file to the recipient.
-
RESPONSE: yes
-
BODY: [FILE_ID, NUM_CHUNKS ,CONTACT_ID]
-
FILE_ID: [BDF raw] A unique identifier which specifies the offered file. NOTE: The identifier is the encrypted stream's sha256 sum and is also used to verify the file
-
NUM_CHUNKS: [BDF long] Specifies how many chunks the file consists of. Note: Chunks, except for the last one, have a fixed size:
CHUNK_SIZE
-
CONTACT_ID: [BDF long/null] Either
Null
, if the contact's id is identified by the connection (A contact of the owner connecting to the owner's mailbox is only allowed to store their own streams) orInteger
to indicate for which id the stream should be stored (Used by the owner storing streams for contacts without their own mailbox)
-
CHUNK
A CHUNK request contains a chunk of a previously offered file. Note: Since the OFFER request already specifies the contact's Id, we do add the contact's id to the CHUNK request
-
RESPONSE: yes
-
BODY: [CHUNK_INDEX, CHUNK]
- CHUNK_INDEX: [BDF long] Defines the chunk's index in the chunked file
- CHUNK: [BDF raw] chunk
SYNC
SYNC requests are used to carry BSP messages between the mailbox and the connected client.
-
RESPONSE: no
-
BODY: [STREAM]
-
STREAM: [BDF raw/null] Either bytes containing a collection of BSP messages or
null
to indicate an "end of stream"
-
STREAM: [BDF raw/null] Either bytes containing a collection of BSP messages or
END
The END request indicates that the sending peer does not have any messages left to send and wishes to close the connection. If both peers have received an END request, the connection can be closed.
- RESPONSE: no
- BODY: No elements