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
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.
Trait Implementations§
impl Eq for Attribute
impl StructuralPartialEq for Attribute
Auto Trait Implementations§
impl Freeze for Attribute
impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnsafeUnpin for Attribute
impl UnwindSafe for Attribute
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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