Struct bgpkit_parser::models::elem::BgpElem
source · pub struct BgpElem {Show 18 fields
pub timestamp: f64,
pub elem_type: ElemType,
pub peer_ip: IpAddr,
pub peer_asn: Asn,
pub prefix: NetworkPrefix,
pub next_hop: Option<IpAddr>,
pub as_path: Option<AsPath>,
pub origin_asns: Option<Vec<Asn>>,
pub origin: Option<Origin>,
pub local_pref: Option<u32>,
pub med: Option<u32>,
pub communities: Option<Vec<MetaCommunity>>,
pub atomic: bool,
pub aggr_asn: Option<Asn>,
pub aggr_ip: Option<BgpIdentifier>,
pub only_to_customer: Option<Asn>,
pub unknown: Option<Vec<AttrRaw>>,
pub deprecated: Option<Vec<AttrRaw>>,
}
Expand description
BgpElem represents a per-prefix BGP element.
This struct contains information about an announced/withdrawn prefix.
Fields:
timestamp
: The time when the BGP element was received.elem_type
: The type of BGP element.peer_ip
: The IP address of the BGP peer.peer_asn
: The ASN of the BGP peer.prefix
: The network prefix.next_hop
: The next hop IP address.as_path
: The AS path.origin_asns
: The list of origin ASNs.origin
: The origin attribute, i.e. IGP, EGP, or INCOMPLETE.local_pref
: The local preference value.med
: The multi-exit discriminator value.communities
: The list of BGP communities.atomic
: Flag indicating if the announcement is atomic.aggr_asn
: The aggregated ASN.aggr_ip
: The aggregated IP address.only_to_customer
: The AS number to which the prefix is only announced.unknown
: Unknown attributes formatted as (TYPE, RAW_BYTES).deprecated
: Deprecated attributes formatted as (TYPE, RAW_BYTES).
Note: Constructing BGP elements consumes more memory due to duplicate information shared between multiple elements of one MRT record.
Fields§
§timestamp: f64
The timestamp of the item in floating-point format.
elem_type: ElemType
The element type of an item.
peer_ip: IpAddr
The IP address of the peer associated with the item.
peer_asn: Asn
The peer ASN (Autonomous System Number) of the item.
prefix: NetworkPrefix
The network prefix of the item.
next_hop: Option<IpAddr>
The next hop IP address for the item, if available.
as_path: Option<AsPath>
The optional path representation of the item.
This field is of type Option<AsPath>
, which means it can either contain
a value of type AsPath
or be None
.
origin_asns: Option<Vec<Asn>>
The origin ASNs associated with the prefix, if available.
§Remarks
An Option
type is used to indicate that the origin_asns
field may or may not have a value.
If it has a value, it will be a Vec
(vector) of Asn
objects representing the ASNs.
If it does not have a value, it will be None
.
origin: Option<Origin>
The origin of the item (IGP, EGP, INCOMPLETE), if known. Can be None
if the origin is not available.
local_pref: Option<u32>
The local preference of the item, if available, represented as an option of unsigned 32-bit integer.
med: Option<u32>
The number of medical items in an option format.
communities: Option<Vec<MetaCommunity>>
A vector of optional MetaCommunity
values.
§Remarks
MetaCommunity
represents a community metadata.
The Option
type indicates that the vector can be empty or contain MetaCommunity values.
When the Option
is Some
, it means the vector is not empty and contains MetaCommunity values.
When the Option
is None
, it means the vector is empty.
atomic: bool
Indicates whether the item is atomic aggreagte or not.
aggr_asn: Option<Asn>
The aggregated ASN of the item, represented as an optional Asn type.
aggr_ip: Option<BgpIdentifier>
The aggregated IP address of the item, represented as an optional BgpIdentifier, i.e. Ipv4Addr
.
only_to_customer: Option<Asn>
§unknown: Option<Vec<AttrRaw>>
unknown attributes formatted as (TYPE, RAW_BYTES)
deprecated: Option<Vec<AttrRaw>>
deprecated attributes formatted as (TYPE, RAW_BYTES)
Implementations§
source§impl BgpElem
impl BgpElem
sourcepub fn is_announcement(&self) -> bool
pub fn is_announcement(&self) -> bool
Returns true if the element is an announcement.
Most of the time, users do not really need to get the type out, only needs to know if it is an announcement or a withdrawal.
sourcepub fn get_origin_asn_opt(&self) -> Option<u32>
pub fn get_origin_asn_opt(&self) -> Option<u32>
Returns the origin AS number as u32. Returns None if the origin AS number is not present or it’s a AS set.
sourcepub fn get_psv_header() -> String
pub fn get_psv_header() -> String
Returns the PSV header as a string.
The PSV header is a pipe-separated string that represents the fields present in PSV (Prefix Statement Format) records. PSV records are used to describe BGP (Border Gateway Protocol) routing information.
§Example
use bgpkit_parser::BgpElem;
let header = BgpElem::get_psv_header();
assert_eq!(header, "type|timestamp|peer_ip|peer_asn|prefix|as_path|origin_asns|origin|next_hop|local_pref|med|communities|atomic|aggr_asn|aggr_ip|only_to_customer");
Trait Implementations§
source§impl Filterable for BgpElem
impl Filterable for BgpElem
fn match_filter(&self, filter: &Filter) -> bool
fn match_filters(&self, filters: &[Filter]) -> bool
source§impl From<&BgpElem> for Attributes
impl From<&BgpElem> for Attributes
source§impl From<&BgpElem> for BgpUpdateMessage
impl From<&BgpElem> for BgpUpdateMessage
source§impl Ord for BgpElem
impl Ord for BgpElem
source§impl PartialEq for BgpElem
impl PartialEq for BgpElem
source§impl PartialOrd for BgpElem
impl PartialOrd for BgpElem
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for BgpElem
impl StructuralPartialEq for BgpElem
Auto Trait Implementations§
impl Freeze for BgpElem
impl RefUnwindSafe for BgpElem
impl Send for BgpElem
impl Sync for BgpElem
impl Unpin for BgpElem
impl UnwindSafe for BgpElem
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.