pub struct RelayCell {
pub circ_id: u32,
pub command: RelayCommand,
pub command_int: u8,
pub recognized: u16,
pub stream_id: u16,
pub digest: u32,
pub data: Vec<u8>,
pub unused: Vec<u8>,
}Expand description
End-to-end encrypted relay cell.
RELAY cells carry encrypted data through circuits. Each relay cell is encrypted/decrypted at each hop using the circuit’s encryption keys.
§Wire Format
[ CircID ][ 3 (RELAY) ][ Command (1) ][ Recognized (2) ][ StreamID (2) ]
[ Digest (4) ][ Length (2) ][ Data ][ Padding ]§Fields
command- Relay sub-command (DATA, BEGIN, END, etc.)recognized- Zero if cell is for us (used for decryption check)stream_id- Stream identifier within the circuitdigest- Running digest for integrity verificationdata- Payload data
§Stream ID Rules
Some commands require a stream ID, others forbid it:
- Required: BEGIN, DATA, END, CONNECTED, RESOLVE, RESOLVED, BEGIN_DIR
- Forbidden: EXTEND, EXTENDED, TRUNCATE, TRUNCATED, DROP, EXTEND2, EXTENDED2
Fields§
§circ_id: u32Circuit ID this cell belongs to.
command: RelayCommandRelay sub-command.
command_int: u8Integer value of the command.
recognized: u16Recognition field (0 if cell is for us).
stream_id: u16Stream identifier within the circuit.
digest: u32Running digest for integrity.
data: Vec<u8>Payload data.
unused: Vec<u8>Unused padding bytes.
Implementations§
Source§impl RelayCell
impl RelayCell
Sourcepub fn new(
circ_id: u32,
command: RelayCommand,
data: Vec<u8>,
digest: u32,
stream_id: u16,
) -> Result<Self, Error>
pub fn new( circ_id: u32, command: RelayCommand, data: Vec<u8>, digest: u32, stream_id: u16, ) -> Result<Self, Error>
Creates a new RELAY cell.
§Arguments
circ_id- Circuit IDcommand- Relay sub-commanddata- Payload datadigest- Running digest (0 for unencrypted cells)stream_id- Stream identifier
§Errors
Returns Error::Protocol if:
stream_idis 0 but command requires a stream IDstream_idis non-zero but command forbids stream IDs
Trait Implementations§
impl StructuralPartialEq for RelayCell
Auto Trait Implementations§
impl Freeze for RelayCell
impl RefUnwindSafe for RelayCell
impl Send for RelayCell
impl Sync for RelayCell
impl Unpin for RelayCell
impl UnwindSafe for RelayCell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more