Skip to main content

Attribute

Enum Attribute 

Source
pub enum Attribute {
    Username(String),
    Priority(Priority),
    UseCandidate,
    IceControlled(u64),
    IceControlling(u64),
    ErrorCode {
        code: u16,
        reason: String,
    },
    XorMappedAddress(SocketAddr),
    Software(String),
    Unknown {
        kind: u16,
        value: Vec<u8>,
    },
}
Expand description

One STUN attribute, in the profile spec §11.1 lists.

MESSAGE-INTEGRITY and FINGERPRINT are deliberately not variants. They are not attributes a caller chooses to add: they are computed over whatever else is present and must come last, in that order, so Message::encode appends them and nothing else can.

Attribute::Unknown is the hole in that sentence, and it is closed rather than trusted: encoding one whose kind is either of those two types is Error::ReservedAttribute. It is not reachable from the wire — Message::decode matches both types before it ever builds an Unknown — but it is reachable from a caller assembling a message by hand, and a second MESSAGE-INTEGRITY in a message is a message that authenticates as nothing.

Variants§

§

Username(String)

USERNAME (RFC 5389 §15.3), in the direction Peering fixes.

§

Priority(Priority)

PRIORITY (RFC 8445 §7.1.1) — and note §7.1.1’s rule that this is not the candidate’s own priority but the one it would have as a peer-reflexive candidate (spec §4).

Carried as Priority so the RFC 8839 §5.1 range check applies to a value read off the wire as much as to one read out of SDP: spec §6.2 shows that an unchecked priority is what overflows the pair-priority arithmetic, and a check is a place a peer can put one.

§

UseCandidate

USE-CANDIDATE (RFC 8445 §7.1.2): a flag, so a zero-length value.

§

IceControlled(u64)

ICE-CONTROLLED (§7.1.3) carrying the sender’s tiebreaker.

§

IceControlling(u64)

ICE-CONTROLLING (§7.1.3) carrying the sender’s tiebreaker.

§

ErrorCode

ERROR-CODE (RFC 5389 §15.6). 487 is the role conflict of RFC 8445 §7.3.1.1.

The code is held to ERROR_CODES in both directions. On decode that means an error response carrying a class §15.6 does not define is a dropped datagram, which costs the transaction a retransmission rather than an immediate failure — the same fail-closed trade the module documentation records for PRIORITY, and only reachable from a peer that is already violating §15.6’s MUST.

Fields

§code: u16

The three-digit code, reassembled from §15.6’s class and number.

§reason: String

The reason phrase, which is advisory and may be empty.

§

XorMappedAddress(SocketAddr)

XOR-MAPPED-ADDRESS (RFC 5389 §15.2): where the responder saw the request come from.

§

Software(String)

SOFTWARE (RFC 5389 §15.10).

sipx does not put one on its own checks — spec §11.1 lists what a check carries and this is not on it, and a version string on every check is bytes on the wire and a gift to a scanner. It is here because a peer may send one and because RFC 5769’s vectors carry one, and a vector that cannot be encoded is a vector that cannot test the encoder.

§

Unknown

An attribute this profile has no meaning for, kept so the caller can decide.

RFC 5389 §7.3.1 wants a comprehension-required unknown attribute in a request answered with a 420; that is the agent’s decision, not the codec’s, so the bytes survive to it.

Fields

§kind: u16

The attribute type.

§value: Vec<u8>

Its value, unpadded.

Trait Implementations§

Source§

impl Clone for Attribute

Source§

fn clone(&self) -> Attribute

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 Attribute

Source§

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

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

impl PartialEq for Attribute

Source§

fn eq(&self, other: &Attribute) -> 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 Attribute

Source§

impl StructuralPartialEq for Attribute

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,