pub async fn oir_event(&mut self, event: oir::OIRInfo) -> error::Result<()> {
        match event.action {
            oir::Action::ADD => {
                // Add to netstack if not there already.
                let pid = if let Some(p) = self.port_with_topopath(&event.topological_path).await? {
                    info!("port already added {}: {:?}", &event.topological_path, p);
                    p.id
                } else {
                    let info = event.device_information.ok_or(error::Oir::MissingInformation)?;
                    let port =
                        oir::PortDevice::new(&event.file_path, &event.topological_path, info)?;
                    info!("adding port {}: {:?}", &event.topological_path, port);
                    self.hal.add_ethernet_device(event.device_channel.unwrap(), port).await?
                };

                // Verify port manager is consistent.
                if let Some(id) = self.port_manager.port_id(&event.topological_path) {
                    if pid != *id {
                        error!("port {:?} already exists with id {:?}", event.topological_path, id);
                        return Err(error::NetworkManager::Oir(error::Oir::InconsistentState));
                    }
                    return Ok(());
                }

                // Port manager does not know about this port, add it.

                // No version change, this is just a port insertion,
                // not a configuration update.
                self.add_port(pid, &event.topological_path, self.version());

                // Apply initial configuration.
                self.apply_configuration_on_new_port(pid, &event.topological_path).await?
            }
            oir::Action::REMOVE => {
                // Tell portmanager interface is removed. It should keep any config there.
                // Tell LIF manager associated port is gone, keep config there so it can be
                // reapplied if it comes back.
                info!("device {:?} will be removed", event.topological_path);
                // Tell netstack interface is gone.
                oir::remove_interface(&event.topological_path);
            }
        }
        Ok(())
    }
/// Informs network manager of an external event from fuchsia.netstack containing updates to
/// properties associated with an interface.
Informs network manager of an external event from fuchsia.netstack containing updates to
properties associated with an interface.
Informs network manager of an external event from fuchsia . netstack containing updates to properties associated with an interface .
pub async fn oir_event(&mut self, event: oir::OIRInfo) -> error::Result<()> {
        match event.action {
            oir::Action::ADD => {
                // Add to netstack if not there already.
                let pid = if let Some(p) = self.port_with_topopath(&event.topological_path).await? {
                    info!("port already added {}: {:?}", &event.topological_path, p);
                    p.id
                } else {
                    let info = event.device_information.ok_or(error::Oir::MissingInformation)?;
                    let port =
                        oir::PortDevice::new(&event.file_path, &event.topological_path, info)?;
                    info!("adding port {}: {:?}", &event.topological_path, port);
                    self.hal.add_ethernet_device(event.device_channel.unwrap(), port).await?
                };
                // Verify port manager is consistent.
                if let Some(id) = self.port_manager.port_id(&event.topological_path) {
                    if pid != *id {
                        error!("port {:?} already exists with id {:?}", event.topological_path, id);
                        return Err(error::NetworkManager::Oir(error::Oir::InconsistentState));
                    }
                    return Ok(());
                }
                // Port manager does not know about this port, add it.
                // No version change, this is just a port insertion,
                // not a configuration update.
                self.add_port(pid, &event.topological_path, self.version());
                // Apply initial configuration.
                self.apply_configuration_on_new_port(pid, &event.topological_path).await?
            }
            oir::Action::REMOVE => {
                // Tell portmanager interface is removed. It should keep any config there.
                // Tell LIF manager associated port is gone, keep config there so it can be
                // reapplied if it comes back.
                info!("device {:?} will be removed", event.topological_path);
                // Tell netstack interface is gone.
                oir::remove_interface(&event.topological_path);
            }
        }
        Ok(())
    }
pub async fn oir_event ( & mut self , event : oir :: OIRInfo ) -> error :: Result < ( ) > { match event . action { oir :: Action :: ADD => { // Add to netstack if not there already. let pid = if let Some ( p ) = self . port_with_topopath ( & event . topological_path ) . await ? { info ! ( " " event topological_path p ) ; p . id } else { let info = event . device_information . ok_or ( error :: Oir :: MissingInformation ) ? ; let port = oir :: PortDevice :: new ( & event . file_path , & event . topological_path , info ) ? ; info ! ( " " event topological_path port ) ; self . hal . add_ethernet_device ( event . device_channel . unwrap ( ) , port ) . await ? } ; // Verify port manager is consistent. if let Some ( id ) = self . port_manager . port_id ( & event . topological_path ) { if pid != * id { error ! ( " " event topological_path id ) ; return Err ( error :: NetworkManager :: Oir ( error :: Oir :: InconsistentState ) ) ; } return Ok ( ( ) ) ; } // Port manager does not know about this port, add it. // No version change, this is just a port insertion, // not a configuration update. self . add_port ( pid , & event . topological_path , self . version ( ) ) ; // Apply initial configuration. self . apply_configuration_on_new_port ( pid , & event . topological_path ) . await ? } oir :: Action :: REMOVE => { // Tell portmanager interface is removed. It should keep any config there. // Tell LIF manager associated port is gone, keep config there so it can be // reapplied if it comes back. info ! ( " " event topological_path ) ; // Tell netstack interface is gone. oir :: remove_interface ( & event . topological_path ) ; } } Ok ( ( ) ) }
Informs network manager of an external event from fuchsia.netstack containing updates to
properties associated with an interface.
Informs network manager of an external event from fuchsia . netstack containing updates to properties associated with an interface .
&mut self
event
oir::OIRInfo
&mut self
event
oir::OIRInfo