-
Notifications
You must be signed in to change notification settings - Fork 6
Core format
This is a description of the transit-independent, extensible PearDrop protocol.
All offsets are in big endian, and offsets and lengths are in bytes.
In bitfields, offsets are in little endian, and offsets and lengths are in bits.
Maximum length: 128 bytes
From: sender
To: advertise
Offset | Length | Type | Name | Description |
---|---|---|---|---|
0x0 | 0x1 | u8 |
dname_len | Length of the name of this device. Maximum 30 bytes. |
0x1 | dname_len |
&str |
dname | The name of this device. Maximum length of 30 bytes. |
0x1f | 0x20 | SHA-256 hash ([u8; 8] ) |
ssid | The SHA-256 hash of the currently connected SSID. Empty if the device is not connected to a WiFi network. |
0x3f | 0x1 | u8 |
name_len | Length of the name of the advertised file. Maximum 32 bytes. |
0x40 | name_len |
&str |
name | Name of the advertised file. Maximum length of 32 bytes. |
0x60 | 0x1 | u8 |
mt_len | Length of the mimetype of the advertised file. Maximum 30 bytes. |
0x61 | mt_len |
&str |
mimetype | MIME type of the advertised file. Maximum length of 30 bytes. |
0x7f | 0x1 | AdFlags |
flags | Extra flags indicating the capabilities of this device. See below for the definition of the AdFlags bitfield. |
Reserved for extensions.
Maximum length: 128 bytes
From: sender
To: single receiver
Offset | Length | Type | Name | Description |
---|---|---|---|---|
0x0 | 0x1 | u8 |
ext_len | Length of the extensions information structure. Maximum of 32 entries. |
0x1 | max 0x77 | [Extension; ext_len] |
exts | The extensions in this packet. Maximum 119 bytes total. |
0x78 | 0x8 | `u64 | len | Length of the data. |
Reserved for extensions. All sub-structs must have these fields at the start:
Offset | Length | Type | Name | Description |
---|---|---|---|---|
0x0 | 4 bits | ExtType |
type | Type of this extension. |
4 bits | 4 bits | u4 |
len | Length of this entire structure. |
Must fit in a u4
. Reserved for extensions.
Maximum length: 32 bytes
From: receiver
To: sender
Offset | Length | Type | Name | Description |
---|---|---|---|---|
0x0 | 4 bits | ReceiverAcknowledgeType |
type | Type of the packet being acknowledged. |
4 bits | 4 bits | u4 |
ext_len | Length of the extensions. Maximum of 32 entries. |
0x1 | max 0x1f | [Extension; ext_len] |
exts | The extensions in this packet. Maximum 31 bytes total. |
No maximum length. This should be the length specified in the sender packet.
This should be sent over a reliable stream protocol (like TCP), or properly chunked otherwise.
This packet simply consists of the data and nothing else.
Sender Receiver(s) Receiver
------------->
advertisement
<----------------------------
acknowledge: advertisement
---------------------------->
sender packet
<----------------------------
acknowledge: sender
<--------------------------->
(optional) extension handshakes
---------------------------->
data packet
<----------------------------
acknowledge: data
transfer complete :)