pub(super) async fn create_interface(
        tun_device: &fidl_fuchsia_net_tun::DeviceProxy,
        tun_port: &fidl_fuchsia_net_tun::PortProxy,
    ) -> (
        fidl_fuchsia_net_interfaces_admin::DeviceControlProxy,
        fidl_fuchsia_net_interfaces_ext::admin::Control,
        u64,
    ) {
        // Get the information Installer needs to install the device.
        let (network_device, mut port_id) = {
            let (network_device, netdevice_server_end) =
                fidl::endpoints::create_proxy::<fidl_fuchsia_hardware_network::DeviceMarker>()
                    .expect("failed to create netdevice proxy");
            let (port, port_server_end) =
                fidl::endpoints::create_proxy::<fidl_fuchsia_hardware_network::PortMarker>()
                    .expect("failed to create port proxy");

            let () = tun_device.get_device(netdevice_server_end).expect("get_device failed");
            let () = tun_port.get_port(port_server_end).expect("get_port failed");
            let port_id = port.get_info().await.expect("get_info failed").id.expect("missing id");
            let network_device: fidl::endpoints::ClientEnd<_> = network_device
                .into_channel()
                .expect("failed to get inner channel")
                .into_zx_channel()
                .into();
            (network_device, port_id)
        };

        // Connect to Installer and install the device.
        let installer = fuchsia_component::client::connect_to_protocol::<
            fidl_fuchsia_net_interfaces_admin::InstallerMarker,
        >()
        .expect("failed to connect to installer");
        let device_control = {
            let (control, server_end) = fidl::endpoints::create_proxy::<
                fidl_fuchsia_net_interfaces_admin::DeviceControlMarker,
            >()
            .expect("create proxy");
            let () = installer
                .install_device(network_device, server_end)
                .expect("install_device failed");
            control
        };
        let control = {
            let (control, server_end) =
                fidl_fuchsia_net_interfaces_ext::admin::Control::create_endpoints()
                    .expect("create endpoints");
            let () = device_control
                .create_interface(
                    &mut port_id,
                    server_end,
                    fidl_fuchsia_net_interfaces_admin::Options::EMPTY,
                )
                .expect("create_interface failed");
            control
        };

        // Enable the interface.
        let did_enable = control.enable().await.expect("enable FIDL error").expect("enable failed");
        assert!(did_enable);

        // Retrieve the interface ID.
        let interface_id = control.get_id().await.expect("get_id failed");
        (device_control, control, interface_id)
    }
/// Installs the provided port on the stack.
Installs the provided port on the stack.
Installs the provided port on the stack .
pub(super) async fn create_interface(
        tun_device: &fidl_fuchsia_net_tun::DeviceProxy,
        tun_port: &fidl_fuchsia_net_tun::PortProxy,
    ) -> (
        fidl_fuchsia_net_interfaces_admin::DeviceControlProxy,
        fidl_fuchsia_net_interfaces_ext::admin::Control,
        u64,
    ) {
        // Get the information Installer needs to install the device.
        let (network_device, mut port_id) = {
            let (network_device, netdevice_server_end) =
                fidl::endpoints::create_proxy::<fidl_fuchsia_hardware_network::DeviceMarker>()
                    .expect("failed to create netdevice proxy");
            let (port, port_server_end) =
                fidl::endpoints::create_proxy::<fidl_fuchsia_hardware_network::PortMarker>()
                    .expect("failed to create port proxy");
            let () = tun_device.get_device(netdevice_server_end).expect("get_device failed");
            let () = tun_port.get_port(port_server_end).expect("get_port failed");
            let port_id = port.get_info().await.expect("get_info failed").id.expect("missing id");
            let network_device: fidl::endpoints::ClientEnd<_> = network_device
                .into_channel()
                .expect("failed to get inner channel")
                .into_zx_channel()
                .into();
            (network_device, port_id)
        };
        // Connect to Installer and install the device.
        let installer = fuchsia_component::client::connect_to_protocol::<
            fidl_fuchsia_net_interfaces_admin::InstallerMarker,
        >()
        .expect("failed to connect to installer");
        let device_control = {
            let (control, server_end) = fidl::endpoints::create_proxy::<
                fidl_fuchsia_net_interfaces_admin::DeviceControlMarker,
            >()
            .expect("create proxy");
            let () = installer
                .install_device(network_device, server_end)
                .expect("install_device failed");
            control
        };
        let control = {
            let (control, server_end) =
                fidl_fuchsia_net_interfaces_ext::admin::Control::create_endpoints()
                    .expect("create endpoints");
            let () = device_control
                .create_interface(
                    &mut port_id,
                    server_end,
                    fidl_fuchsia_net_interfaces_admin::Options::EMPTY,
                )
                .expect("create_interface failed");
            control
        };
        // Enable the interface.
        let did_enable = control.enable().await.expect("enable FIDL error").expect("enable failed");
        assert!(did_enable);
        // Retrieve the interface ID.
        let interface_id = control.get_id().await.expect("get_id failed");
        (device_control, control, interface_id)
    }
pub ( super ) async fn create_interface ( tun_device : & fidl_fuchsia_net_tun :: DeviceProxy , tun_port : & fidl_fuchsia_net_tun :: PortProxy , ) -> ( fidl_fuchsia_net_interfaces_admin :: DeviceControlProxy , fidl_fuchsia_net_interfaces_ext :: admin :: Control , u64 , ) { // Get the information Installer needs to install the device. let ( network_device , mut port_id ) = { let ( network_device , netdevice_server_end ) = fidl :: endpoints :: create_proxy :: < fidl_fuchsia_hardware_network :: DeviceMarker > ( ) . expect ( " " ) ; let ( port , port_server_end ) = fidl :: endpoints :: create_proxy :: < fidl_fuchsia_hardware_network :: PortMarker > ( ) . expect ( " " ) ; let ( ) = tun_device . get_device ( netdevice_server_end ) . expect ( " " ) ; let ( ) = tun_port . get_port ( port_server_end ) . expect ( " " ) ; let port_id = port . get_info ( ) . await . expect ( " " ) . id . expect ( " " ) ; let network_device : fidl :: endpoints :: ClientEnd < _ > = network_device . into_channel ( ) . expect ( " " ) . into_zx_channel ( ) . into ( ) ; ( network_device , port_id ) } ; // Connect to Installer and install the device. let installer = fuchsia_component :: client :: connect_to_protocol :: < fidl_fuchsia_net_interfaces_admin :: InstallerMarker , > ( ) . expect ( " " ) ; let device_control = { let ( control , server_end ) = fidl :: endpoints :: create_proxy :: < fidl_fuchsia_net_interfaces_admin :: DeviceControlMarker , > ( ) . expect ( " " ) ; let ( ) = installer . install_device ( network_device , server_end ) . expect ( " " ) ; control } ; let control = { let ( control , server_end ) = fidl_fuchsia_net_interfaces_ext :: admin :: Control :: create_endpoints ( ) . expect ( " " ) ; let ( ) = device_control . create_interface ( & mut port_id , server_end , fidl_fuchsia_net_interfaces_admin :: Options :: EMPTY , ) . expect ( " " ) ; control } ; // Enable the interface. let did_enable = control . enable ( ) . await . expect ( " " ) . expect ( " " ) ; assert ! ( did_enable ) ; // Retrieve the interface ID. let interface_id = control . get_id ( ) . await . expect ( " " ) ; ( device_control , control , interface_id ) }
Installs the provided port on the stack.
Installs the provided port on the stack .
tun_device
&fidl_fuchsia_net_tun::DeviceProxy
tun_port
&fidl_fuchsia_net_tun::PortProxy
tun_device
&fidl_fuchsia_net_tun::DeviceProxy
tun_port
&fidl_fuchsia_net_tun::PortProxy