Struct BgpkitCommons

Source
pub struct BgpkitCommons { /* private fields */ }

Implementations§

Source§

impl BgpkitCommons

Source

pub fn as2rel_lookup( &self, asn1: u32, asn2: u32, ) -> Result<(Vec<As2relBgpkitData>, Vec<As2relBgpkitData>)>

Source§

impl BgpkitCommons

Source

pub fn asinfo_all(&self) -> Result<HashMap<u32, AsInfo>>

Returns a HashMap containing all AS information.

§Returns
  • Ok(HashMap<u32, AsInfo>): A HashMap where the key is the ASN and the value is the corresponding AsInfo.
  • Err: If the asinfo is not loaded.
§Examples
use bgpkit_commons::BgpkitCommons;

let mut bgpkit = BgpkitCommons::new();
bgpkit.load_asinfo(false, false, false, false).unwrap();
let all_asinfo = bgpkit.asinfo_all().unwrap();
Source

pub fn asinfo_get(&self, asn: u32) -> Result<Option<AsInfo>>

Retrieves AS information for a specific ASN.

§Arguments
  • asn - The Autonomous System Number to look up.
§Returns
  • Ok(Some(AsInfo)): The AS information if found.
  • Ok(None): If the ASN is not found in the database.
  • Err: If the asinfo is not loaded.
§Examples
use bgpkit_commons::BgpkitCommons;

let mut bgpkit = BgpkitCommons::new();
bgpkit.load_asinfo(false, false, false, false).unwrap();
let asinfo = bgpkit.asinfo_get(3333).unwrap();
Source

pub fn asinfo_are_siblings(&self, asn1: u32, asn2: u32) -> Result<bool>

Checks if two ASNs are siblings (belong to the same organization).

§Arguments
  • asn1 - The first Autonomous System Number.
  • asn2 - The second Autonomous System Number.
§Returns
  • Ok(bool): True if the ASNs are siblings, false otherwise.
  • Err: If the asinfo is not loaded or not loaded with as2org data.
§Examples
use bgpkit_commons::BgpkitCommons;

let mut bgpkit = BgpkitCommons::new();
bgpkit.load_asinfo(true, false, false, false).unwrap();
let are_siblings = bgpkit.asinfo_are_siblings(3333, 3334).unwrap();
§Note

This function requires the asinfo to be loaded with as2org data.

Source§

impl BgpkitCommons

Source

pub fn bogons_match(&self, s: &str) -> Result<bool>

Source

pub fn bogons_match_prefix(&self, prefix: &str) -> Result<bool>

Source

pub fn bogons_match_asn(&self, asn: u32) -> Result<bool>

Source

pub fn get_bogon_prefixes(&self) -> Result<Vec<BogonPrefix>>

Get all bogon prefixes.

Source

pub fn get_bogon_asns(&self) -> Result<Vec<BogonAsn>>

Get all bogon ASNs.

Source§

impl BgpkitCommons

Source

pub fn country_all(&self) -> Result<Vec<Country>>

Source

pub fn country_by_code(&self, code: &str) -> Result<Option<Country>>

Source

pub fn country_by_name(&self, name: &str) -> Result<Vec<Country>>

Source

pub fn country_by_code3(&self, code: &str) -> Result<Option<Country>>

Source§

impl BgpkitCommons

Source§

impl BgpkitCommons

Source

pub fn rpki_lookup_by_prefix(&self, prefix: &str) -> Result<Vec<RoaEntry>>

Source

pub fn rpki_validate(&self, asn: u32, prefix: &str) -> Result<RpkiValidation>

Source

pub fn rpki_validate_check_expiry( &self, asn: u32, prefix: &str, check_time: Option<NaiveDateTime>, ) -> Result<RpkiValidation>

Source§

impl BgpkitCommons

Source

pub fn new() -> Self

Source

pub fn reload(&mut self) -> Result<()>

Reload all data sources that are already loaded

Source

pub fn loading_status(&self) -> Vec<(&'static str, &'static str)>

Get loading status for all available modules

Source

pub fn load_countries(&mut self) -> Result<()>

Load countries data

Source

pub fn load_rpki(&mut self, date_opt: Option<NaiveDate>) -> Result<()>

Load RPKI data

Source

pub fn load_mrt_collectors(&mut self) -> Result<()>

Load MRT mrt_collectors data

Source

pub fn load_mrt_collector_peers(&mut self) -> Result<()>

Load MRT mrt_collectors data

Source

pub fn load_bogons(&mut self) -> Result<()>

Load bogons data

Source

pub fn load_asinfo( &mut self, load_as2org: bool, load_population: bool, load_hegemony: bool, load_peeringdb: bool, ) -> Result<()>

Load AS name and country data

Source

pub fn load_asinfo_cached(&mut self) -> Result<()>

Source

pub fn load_as2rel(&mut self) -> Result<()>

Load AS-level relationship data

Trait Implementations§

Source§

impl Default for BgpkitCommons

Source§

fn default() -> BgpkitCommons

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,