pub(super) async fn add_interface_address(
        control: &fidl_fuchsia_net_interfaces_ext::admin::Control,
        interface_id: u64,
        subnet: fidl_fuchsia_net::Subnet,
    ) {
        let (address_state_provider, server_end) = fidl::endpoints::create_proxy::<
            fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
        >()
        .expect("create proxy");
        // AddressStateProvider allows us to tie the lifetime of the address to
        // this proxy, opt out by detaching.
        let () = address_state_provider.detach().expect("detach failed");

        let mut interface_addr = {
            let fidl_fuchsia_net::Subnet { addr, prefix_len } = &subnet;
            match addr {
                fidl_fuchsia_net::IpAddress::Ipv4(addr) => {
                    fidl_fuchsia_net::InterfaceAddress::Ipv4(
                        fidl_fuchsia_net::Ipv4AddressWithPrefix {
                            addr: addr.clone(),
                            prefix_len: *prefix_len,
                        },
                    )
                }
                fidl_fuchsia_net::IpAddress::Ipv6(addr) => {
                    fidl_fuchsia_net::InterfaceAddress::Ipv6(addr.clone())
                }
            }
        };

        let () = control
            .add_address(
                &mut interface_addr,
                fidl_fuchsia_net_interfaces_admin::AddressParameters::EMPTY,
                server_end,
            )
            .expect("add_address failed");
        // Wait for the address to be assigned.
        let () = fidl_fuchsia_net_interfaces_ext::admin::wait_assignment_state(
            &mut fidl_fuchsia_net_interfaces_ext::admin::assignment_state_stream(
                address_state_provider,
            ),
            fidl_fuchsia_net_interfaces_admin::AddressAssignmentState::Assigned,
        )
        .await
        .expect("failed to observe assigned address");

        // NB: Adding an address does not add the subnet route, we still have to
        // add that so we can exchange frames.
        let stack =
            fuchsia_component::client::connect_to_protocol::<fidl_fuchsia_net_stack::StackMarker>()
                .expect("failed to connect to stack");
        let () = stack
            .add_forwarding_entry(&mut fidl_fuchsia_net_stack::ForwardingEntry {
                subnet: fidl_fuchsia_net_ext::apply_subnet_mask(subnet),
                device_id: interface_id,
                next_hop: None,
                metric: 0,
            })
            .await
            .expect("add_forwarding_entry FIDL error")
            .expect("add_forwarding_entry failed");
    }
/// Adds an address to an installed interface.
Adds an address to an installed interface.
Adds an address to an installed interface .
pub(super) async fn add_interface_address(
        control: &fidl_fuchsia_net_interfaces_ext::admin::Control,
        interface_id: u64,
        subnet: fidl_fuchsia_net::Subnet,
    ) {
        let (address_state_provider, server_end) = fidl::endpoints::create_proxy::<
            fidl_fuchsia_net_interfaces_admin::AddressStateProviderMarker,
        >()
        .expect("create proxy");
        // AddressStateProvider allows us to tie the lifetime of the address to
        // this proxy, opt out by detaching.
        let () = address_state_provider.detach().expect("detach failed");
        let mut interface_addr = {
            let fidl_fuchsia_net::Subnet { addr, prefix_len } = &subnet;
            match addr {
                fidl_fuchsia_net::IpAddress::Ipv4(addr) => {
                    fidl_fuchsia_net::InterfaceAddress::Ipv4(
                        fidl_fuchsia_net::Ipv4AddressWithPrefix {
                            addr: addr.clone(),
                            prefix_len: *prefix_len,
                        },
                    )
                }
                fidl_fuchsia_net::IpAddress::Ipv6(addr) => {
                    fidl_fuchsia_net::InterfaceAddress::Ipv6(addr.clone())
                }
            }
        };
        let () = control
            .add_address(
                &mut interface_addr,
                fidl_fuchsia_net_interfaces_admin::AddressParameters::EMPTY,
                server_end,
            )
            .expect("add_address failed");
        // Wait for the address to be assigned.
        let () = fidl_fuchsia_net_interfaces_ext::admin::wait_assignment_state(
            &mut fidl_fuchsia_net_interfaces_ext::admin::assignment_state_stream(
                address_state_provider,
            ),
            fidl_fuchsia_net_interfaces_admin::AddressAssignmentState::Assigned,
        )
        .await
        .expect("failed to observe assigned address");
        // NB: Adding an address does not add the subnet route, we still have to
        // add that so we can exchange frames.
        let stack =
            fuchsia_component::client::connect_to_protocol::<fidl_fuchsia_net_stack::StackMarker>()
                .expect("failed to connect to stack");
        let () = stack
            .add_forwarding_entry(&mut fidl_fuchsia_net_stack::ForwardingEntry {
                subnet: fidl_fuchsia_net_ext::apply_subnet_mask(subnet),
                device_id: interface_id,
                next_hop: None,
                metric: 0,
            })
            .await
            .expect("add_forwarding_entry FIDL error")
            .expect("add_forwarding_entry failed");
    }
pub ( super ) async fn add_interface_address ( control : & fidl_fuchsia_net_interfaces_ext :: admin :: Control , interface_id : u64 , subnet : fidl_fuchsia_net :: Subnet , ) { let ( address_state_provider , server_end ) = fidl :: endpoints :: create_proxy :: < fidl_fuchsia_net_interfaces_admin :: AddressStateProviderMarker , > ( ) . expect ( " " ) ; // AddressStateProvider allows us to tie the lifetime of the address to // this proxy, opt out by detaching. let ( ) = address_state_provider . detach ( ) . expect ( " " ) ; let mut interface_addr = { let fidl_fuchsia_net :: Subnet { addr , prefix_len } = & subnet ; match addr { fidl_fuchsia_net :: IpAddress :: Ipv4 ( addr ) => { fidl_fuchsia_net :: InterfaceAddress :: Ipv4 ( fidl_fuchsia_net :: Ipv4AddressWithPrefix { addr : addr . clone ( ) , prefix_len : * prefix_len , } , ) } fidl_fuchsia_net :: IpAddress :: Ipv6 ( addr ) => { fidl_fuchsia_net :: InterfaceAddress :: Ipv6 ( addr . clone ( ) ) } } } ; let ( ) = control . add_address ( & mut interface_addr , fidl_fuchsia_net_interfaces_admin :: AddressParameters :: EMPTY , server_end , ) . expect ( " " ) ; // Wait for the address to be assigned. let ( ) = fidl_fuchsia_net_interfaces_ext :: admin :: wait_assignment_state ( & mut fidl_fuchsia_net_interfaces_ext :: admin :: assignment_state_stream ( address_state_provider , ) , fidl_fuchsia_net_interfaces_admin :: AddressAssignmentState :: Assigned , ) . await . expect ( " " ) ; // NB: Adding an address does not add the subnet route, we still have to // add that so we can exchange frames. let stack = fuchsia_component :: client :: connect_to_protocol :: < fidl_fuchsia_net_stack :: StackMarker > ( ) . expect ( " " ) ; let ( ) = stack . add_forwarding_entry ( & mut fidl_fuchsia_net_stack :: ForwardingEntry { subnet : fidl_fuchsia_net_ext :: apply_subnet_mask ( subnet ) , device_id : interface_id , next_hop : None , metric : 0 , } ) . await . expect ( " " ) . expect ( " " ) ; }
Adds an address to an installed interface.
Adds an address to an installed interface .
control
&fidl_fuchsia_net_interfaces_ext::admin::Control
interface_id
u64
subnet
fidl_fuchsia_net::Subnet
control
&fidl_fuchsia_net_interfaces_ext::admin::Control
interface_id
u64
subnet
fidl_fuchsia_net::Subnet