pub struct OspfRouter {
pub router_id: u32,
pub area_id: u32,
/* private fields */
}Expand description
OSPF Router
Fields§
§router_id: u32This router’s ID
area_id: u32Area ID (0 for backbone)
Implementations§
Source§impl OspfRouter
impl OspfRouter
Sourcepub fn new(
router_id: u32,
area_id: u32,
priority: u8,
network_mask: u32,
) -> Self
pub fn new( router_id: u32, area_id: u32, priority: u8, network_mask: u32, ) -> Self
Create a new OSPF router
Sourcepub fn lsdb(&self) -> &LsDatabase
pub fn lsdb(&self) -> &LsDatabase
Get the link-state database
Sourcepub fn lsdb_mut(&mut self) -> &mut LsDatabase
pub fn lsdb_mut(&mut self) -> &mut LsDatabase
Get the link-state database mutably
Sourcepub fn neighbor_count(&self) -> usize
pub fn neighbor_count(&self) -> usize
Get number of neighbors
Sourcepub fn get_neighbor(&self, router_id: u32) -> Option<&OspfNeighbor>
pub fn get_neighbor(&self, router_id: u32) -> Option<&OspfNeighbor>
Get a neighbor by router ID
Sourcepub fn neighbors(&self) -> Vec<&OspfNeighbor>
pub fn neighbors(&self) -> Vec<&OspfNeighbor>
Get all neighbors
Sourcepub fn process_hello(
&mut self,
header: &OspfHeader,
hello: &HelloPacket,
source: Ipv4Address,
)
pub fn process_hello( &mut self, header: &OspfHeader, hello: &HelloPacket, source: Ipv4Address, )
Process an incoming Hello packet from a neighbor
Sourcepub fn process_dbd(&mut self, header: &OspfHeader, _lsa_headers: &[LsaHeader])
pub fn process_dbd(&mut self, header: &OspfHeader, _lsa_headers: &[LsaHeader])
Process a Database Description packet (simplified: just advance state)
Sourcepub fn install_lsa(&mut self, lsa: Lsa) -> bool
pub fn install_lsa(&mut self, lsa: Lsa) -> bool
Install an LSA into the database and return whether SPF recalculation is needed
Sourcepub fn check_dead_neighbors(&mut self)
pub fn check_dead_neighbors(&mut self)
Check for dead neighbors and remove them
Sourcepub fn generate_hello(&self) -> HelloPacket
pub fn generate_hello(&self) -> HelloPacket
Generate a Hello packet for this interface