Struct bgpkit_parser::models::PeerIndexTable
source · pub struct PeerIndexTable {
pub collector_bgp_id: BgpIdentifier,
pub view_name: String,
pub id_peer_map: HashMap<u16, Peer>,
pub peer_addr_id_map: HashMap<IpAddr, u16>,
}
Expand description
peer index table.
An initial PEER_INDEX_TABLE MRT record provides the BGP ID of the
collector, an OPTIONAL view name, and a list of indexed peers.
Following the PEER_INDEX_TABLE MRT record, a series of MRT records is
used to encode RIB table entries. This series of MRT records uses
subtypes 2-6 and is separate from the PEER_INDEX_TABLE MRT record
itself and includes full MRT record headers. The RIB entry MRT
records MUST immediately follow the PEER_INDEX_TABLE MRT record.
Fields§
§collector_bgp_id: BgpIdentifier
§view_name: String
§id_peer_map: HashMap<u16, Peer>
§peer_addr_id_map: HashMap<IpAddr, u16>
Implementations§
source§impl PeerIndexTable
impl PeerIndexTable
sourcepub fn get_peer_by_id(&self, peer_id: &u16) -> Option<&Peer>
pub fn get_peer_by_id(&self, peer_id: &u16) -> Option<&Peer>
sourcepub fn get_peer_id_by_addr(&self, peer_addr: &IpAddr) -> Option<u16>
pub fn get_peer_id_by_addr(&self, peer_addr: &IpAddr) -> Option<u16>
Returns the peer ID associated with the given IP address.
§Arguments
peer_addr
- The IP address of the peer.
§Returns
An optional u16
representing the peer ID. Returns None
if the IP address is not found.
§Examples
use std::net::IpAddr;
use std::str::FromStr;
use bgpkit_parser::models::PeerIndexTable;
let index_table = PeerIndexTable::default();
let peer_addr = IpAddr::from_str("127.0.0.1").unwrap();
let peer_id = index_table.get_peer_id_by_addr(&peer_addr);
sourcepub fn encode(&self) -> Bytes
pub fn encode(&self) -> Bytes
Encode the data in the struct into a byte array.
§Returns
A Bytes
object containing the encoded data.
§Example
use std::collections::HashMap;
use std::net::Ipv4Addr;
use bgpkit_parser::models::PeerIndexTable;
let data = PeerIndexTable {
collector_bgp_id: Ipv4Addr::from(1234),
view_name: String::from("example"),
id_peer_map: HashMap::new(),
peer_addr_id_map: Default::default(),
};
let encoded = data.encode();
Trait Implementations§
source§impl Clone for PeerIndexTable
impl Clone for PeerIndexTable
source§fn clone(&self) -> PeerIndexTable
fn clone(&self) -> PeerIndexTable
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PeerIndexTable
impl Debug for PeerIndexTable
source§impl Default for PeerIndexTable
impl Default for PeerIndexTable
source§impl PartialEq for PeerIndexTable
impl PartialEq for PeerIndexTable
source§fn eq(&self, other: &PeerIndexTable) -> bool
fn eq(&self, other: &PeerIndexTable) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for PeerIndexTable
impl StructuralPartialEq for PeerIndexTable
Auto Trait Implementations§
impl Freeze for PeerIndexTable
impl RefUnwindSafe for PeerIndexTable
impl Send for PeerIndexTable
impl Sync for PeerIndexTable
impl Unpin for PeerIndexTable
impl UnwindSafe for PeerIndexTable
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
Mutably borrows from an owned value. Read more
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
Compare self to
key
and return true
if they are equal.