pub(super) fn select_ipv6_source_address<
        'a,
        Instant: 'a,
        I: Iterator<Item = (&'a AddressEntry<Ipv6Addr, Instant, UnicastAddr<Ipv6Addr>>, DeviceId)>,
    >(
        remote_ip: SpecifiedAddr<Ipv6Addr>,
        outbound_device: DeviceId,
        addresses: I,
    ) -> Option<UnicastAddr<Ipv6Addr>> {
        // Source address selection as defined in RFC 6724 Section 5.
        //
        // The algorithm operates by defining a partial ordering on available
        // source addresses, and choosing one of the best address as defined by
        // that ordering (given multiple best addresses, the choice from among
        // those is implementation-defined). The partial order is defined in
        // terms of a sequence of rules. If a given rule defines an order
        // between two addresses, then that is their order. Otherwise, the next
        // rule must be consulted, and so on until all of the rules are
        // exhausted.

        addresses
            // Tentative addresses are not considered available to the source
            // selection algorithm.
            .filter(|(a, _)| !a.state().is_tentative())
            .max_by(|(a, a_device), (b, b_device)| {
                select_ipv6_source_address_cmp(
                    remote_ip,
                    outbound_device,
                    a,
                    *a_device,
                    b,
                    *b_device,
                )
            })
            .map(|(addr, _device)| addr.addr_sub().addr())
    }
/// Selects the source address for an IPv6 socket using the algorithm
/// defined in [RFC 6724 Section 5].
///
/// This algorithm is only applicable when the user has not explicitly
/// specified a source address.
///
/// `remote_ip` is the remote IP address of the socket, `outbound_device` is
/// the device over which outbound traffic to `remote_ip` is sent (according
/// to the forwarding table), and `addresses` is an iterator of all
/// addresses on all devices. The algorithm works by iterating over
/// `addresses` and selecting the address which is most preferred according
/// to a set of selection criteria.
Selects the source address for an IPv6 socket using the algorithm
defined in [RFC 6724 Section 5].

This algorithm is only applicable when the user has not explicitly
specified a source address.


Selects the source address for an IPv6 socket using the algorithm defined in [ RFC 6724 Section 5 ] . This algorithm is only applicable when the user has not explicitly specified a source address .
pub(super) fn select_ipv6_source_address<
        'a,
        Instant: 'a,
        I: Iterator<Item = (&'a AddressEntry<Ipv6Addr, Instant, UnicastAddr<Ipv6Addr>>, DeviceId)>,
    >(
        remote_ip: SpecifiedAddr<Ipv6Addr>,
        outbound_device: DeviceId,
        addresses: I,
    ) -> Option<UnicastAddr<Ipv6Addr>> {
        // Source address selection as defined in RFC 6724 Section 5.
        //
        // The algorithm operates by defining a partial ordering on available
        // source addresses, and choosing one of the best address as defined by
        // that ordering (given multiple best addresses, the choice from among
        // those is implementation-defined). The partial order is defined in
        // terms of a sequence of rules. If a given rule defines an order
        // between two addresses, then that is their order. Otherwise, the next
        // rule must be consulted, and so on until all of the rules are
        // exhausted.
        addresses
            // Tentative addresses are not considered available to the source
            // selection algorithm.
            .filter(|(a, _)| !a.state().is_tentative())
            .max_by(|(a, a_device), (b, b_device)| {
                select_ipv6_source_address_cmp(
                    remote_ip,
                    outbound_device,
                    a,
                    *a_device,
                    b,
                    *b_device,
                )
            })
            .map(|(addr, _device)| addr.addr_sub().addr())
    }
pub ( super ) fn select_ipv6_source_address < ' a , Instant : ' a , I : Iterator < Item = ( & ' a AddressEntry < Ipv6Addr , Instant , UnicastAddr < Ipv6Addr > > , DeviceId ) > , > ( remote_ip : SpecifiedAddr < Ipv6Addr > , outbound_device : DeviceId , addresses : I , ) -> Option < UnicastAddr < Ipv6Addr > > { // Source address selection as defined in RFC 6724 Section 5. // // The algorithm operates by defining a partial ordering on available // source addresses, and choosing one of the best address as defined by // that ordering (given multiple best addresses, the choice from among // those is implementation-defined). The partial order is defined in // terms of a sequence of rules. If a given rule defines an order // between two addresses, then that is their order. Otherwise, the next // rule must be consulted, and so on until all of the rules are // exhausted. addresses // Tentative addresses are not considered available to the source // selection algorithm. . filter ( | ( a , _ ) | ! a . state ( ) . is_tentative ( ) ) . max_by ( | ( a , a_device ) , ( b , b_device ) | { select_ipv6_source_address_cmp ( remote_ip , outbound_device , a , * a_device , b , * b_device , ) } ) . map ( | ( addr , _device ) | addr . addr_sub ( ) . addr ( ) ) }
Selects the source address for an IPv6 socket using the algorithm
defined in [RFC 6724 Section 5].
Selects the source address for an IPv6 socket using the algorithm defined in [ RFC 6724 Section 5 ] .
remote_ip
SpecifiedAddr<Ipv6Addr>
outbound_device
DeviceId
addresses
I
remote_ip
SpecifiedAddr<Ipv6Addr>
outbound_device
DeviceId
addresses
I