pub struct Attributes { /* private fields */ }Expand description
Convenience wrapper for a list of attributes
Implementations§
Source§impl Attributes
impl Attributes
pub fn has_attr(&self, ty: AttrType) -> bool
pub fn get_attr(&self, ty: AttrType) -> Option<Attribute>
pub fn add_attr(&mut self, attr: Attribute)
Sourcepub fn check_mandatory_attributes(
&mut self,
is_announcement: bool,
has_standard_nlri: bool,
)
pub fn check_mandatory_attributes( &mut self, is_announcement: bool, has_standard_nlri: bool, )
Check for missing well-known mandatory attributes.
RFC 4271 (BGP-4) and RFC 4760 (MP-BGP) define which attributes are mandatory.
- Pure Withdrawals: NO path attributes are required.
- Announcements: ORIGIN and AS_PATH are strictly required.
- NEXT_HOP is required if standard IPv4 NLRI is present or if no MP_REACH_NLRI is present.
Sourcepub fn add_validation_warning(&mut self, warning: BgpValidationWarning)
pub fn add_validation_warning(&mut self, warning: BgpValidationWarning)
Add a validation warning to the attributes
Sourcepub fn validation_warnings(&self) -> &[BgpValidationWarning]
pub fn validation_warnings(&self) -> &[BgpValidationWarning]
Get all validation warnings for these attributes
Sourcepub fn has_validation_warnings(&self) -> bool
pub fn has_validation_warnings(&self) -> bool
Check if there are any validation warnings
Sourcepub fn origin(&self) -> Origin
pub fn origin(&self) -> Origin
Get the ORIGIN attribute. In the event that this attribute is not present,
Origin::INCOMPLETE will be returned instead.
Sourcepub fn origin_id(&self) -> Option<BgpIdentifier>
pub fn origin_id(&self) -> Option<BgpIdentifier>
Get the ORIGINATOR_ID attribute if present.
Sourcepub fn next_hop(&self) -> Option<IpAddr>
pub fn next_hop(&self) -> Option<IpAddr>
Get the NEXT_HOP attribute if present.
Note: Even when this attribute is not present, the next hop address may still be
attainable from the MP_REACH_NLRI attribute.
pub fn multi_exit_discriminator(&self) -> Option<u32>
pub fn local_preference(&self) -> Option<u32>
pub fn only_to_customer(&self) -> Option<Asn>
pub fn atomic_aggregate(&self) -> bool
pub fn aggregator(&self) -> Option<(Asn, BgpIdentifier)>
pub fn clusters(&self) -> Option<&[u32]>
Sourcepub fn as_path(&self) -> Option<&AsPath>
pub fn as_path(&self) -> Option<&AsPath>
Get the AS_PATH (type 2) attribute value, without merging a
coexisting AS4_PATH. See Attributes::effective_as_path for the
RFC 6793 merged path.
Sourcepub fn as4_path(&self) -> Option<&AsPath>
pub fn as4_path(&self) -> Option<&AsPath>
Get the AS4_PATH (type 17) attribute value if present.
Sourcepub fn effective_as_path(&self) -> Option<AsPath>
pub fn effective_as_path(&self) -> Option<AsPath>
Get the effective AS path per RFC 6793 §4.2.3.
When both AS_PATH and AS4_PATH are present (a 2-octet session carrying 4-octet AS numbers), the two are merged: the leading ASes come from the 2-octet AS_PATH and the trailing ASes from the 4-octet AS4_PATH. Otherwise whichever attribute is present is returned as-is.
pub fn get_reachable_nlri(&self) -> Option<&Nlri>
pub fn get_unreachable_nlri(&self) -> Option<&Nlri>
pub fn iter_communities(&self) -> MetaCommunitiesIter<'_> ⓘ
Sourcepub fn iter(&self) -> <&Self as IntoIterator>::IntoIter
pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter
Get an iterator over the held AttributeValues. If you also need attribute flags, consider using Attributes::into_attributes_iter instead.
Sourcepub fn into_attributes_iter(self) -> impl Iterator<Item = Attribute>
pub fn into_attributes_iter(self) -> impl Iterator<Item = Attribute>
Get an iterator over the held Attributes. If you do no not need attribute flags, consider using Attributes::iter instead.
Source§impl Attributes
impl Attributes
Trait Implementations§
Source§impl Clone for Attributes
impl Clone for Attributes
Source§fn clone(&self) -> Attributes
fn clone(&self) -> Attributes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Attributes
impl Debug for Attributes
Source§impl Default for Attributes
impl Default for Attributes
Source§fn default() -> Attributes
fn default() -> Attributes
impl Eq for Attributes
Source§impl Extend<Attribute> for Attributes
impl Extend<Attribute> for Attributes
Source§fn extend<T: IntoIterator<Item = Attribute>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Attribute>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<AttributeValue> for Attributes
impl Extend<AttributeValue> for Attributes
Source§fn extend<T: IntoIterator<Item = AttributeValue>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = AttributeValue>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<&BgpElem> for Attributes
impl From<&BgpElem> for Attributes
Source§impl FromIterator<Attribute> for Attributes
impl FromIterator<Attribute> for Attributes
Source§impl FromIterator<AttributeValue> for Attributes
impl FromIterator<AttributeValue> for Attributes
Source§fn from_iter<T: IntoIterator<Item = AttributeValue>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = AttributeValue>>(iter: T) -> Self
Source§impl IntoIterator for Attributes
impl IntoIterator for Attributes
Source§impl<'a> IntoIterator for &'a Attributes
impl<'a> IntoIterator for &'a Attributes
Source§impl PartialEq for Attributes
impl PartialEq for Attributes
impl StructuralPartialEq for Attributes
Auto Trait Implementations§
impl Freeze for Attributes
impl RefUnwindSafe for Attributes
impl Send for Attributes
impl Sync for Attributes
impl Unpin for Attributes
impl UnsafeUnpin for Attributes
impl UnwindSafe for Attributes
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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