Skip to main content

Replaces

Struct Replaces 

Source
pub struct Replaces {
    pub call_id: Vec<u8>,
    pub to_tag: Vec<u8>,
    pub from_tag: Vec<u8>,
    pub early_only: bool,
}
Expand description

The dialog an INVITE asks to take the place of (RFC 3891).

All three fields are load-bearing, and the two tags are the security. A Call-ID is carried in every message of a dialog and is visible to every element on the path — a proxy, a load balancer, anything that logged a header. The tags are random and known only to the two parties. Matching on the Call-ID alone would turn this header into a call-hijack primitive: anyone who had seen one message of a call could ask to be put in the middle of it.

RFC 3891 §5 says as much, and it is the reason this type has no constructor that takes fewer than three fields.

Fields§

§call_id: Vec<u8>

The Call-ID of the dialog to replace.

§to_tag: Vec<u8>

The To tag, from the point of view of whoever built this header.

§from_tag: Vec<u8>

The From tag, likewise.

§early_only: bool

Whether the sender will only replace a dialog that has not been answered yet.

Implementations§

Source§

impl Replaces

Source

pub fn of(request: &Request) -> Option<Self>

Read a Replaces header out of a request.

None when there is none, and also when there is one that is unusable — a header missing either tag names no dialog, and treating it as though it named one with an empty tag is how the tags stop being a secret.

Source

pub fn parse(value: &[u8]) -> Option<Self>

Parse a header value: call-id;to-tag=x;from-tag=y[;early-only].

Source

pub fn matches(&self, dialog: &Dialog) -> bool

Whether this names that dialog.

The tags swap sides. A Replaces is built by the party that observed the dialog from outside it — in an attended transfer, the transferor describing its own call to the transferee — so the to-tag is the tag of the party receiving this INVITE, which is that party’s local tag. Getting the orientation wrong makes every legitimate transfer fail while leaving the hijack case wide open, because a mismatch is a mismatch either way and only the successful case would have shown it up.

Source

pub fn to_header(&self) -> String

Render as a header value, for the INVITE that asks for the replacement.

Trait Implementations§

Source§

impl Clone for Replaces

Source§

fn clone(&self) -> Replaces

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Replaces

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Replaces

Source§

fn eq(&self, other: &Replaces) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Replaces

Source§

impl StructuralPartialEq for Replaces

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,