/// Processes the given IPv6 packet from the host and determines if it should
/// be forwarded or not.
///
/// Returns true if the packet should be forwarded to the thread network, false otherwise.
Processes the given IPv6 packet from the host and determines if it should
be forwarded or not.

Returns true if the packet should be forwarded to the thread network, false otherwise.
Processes the given IPv6 packet from the host and determines if it should be forwarded or not . Returns true if the packet should be forwarded to the thread network false otherwise .
async fn intercept_from_host(&self, mut packet_bytes: &[u8]) -> bool {
        match Ipv6Packet::parse(&mut packet_bytes, ()) {
            Ok(packet) => match packet.proto() {
                Ipv6Proto::Icmpv6 => {
                    let args = IcmpParseArgs::new(packet.src_ip(), packet.dst_ip());
                    match Icmpv6Packet::parse(&mut packet_bytes, args) {
                        Ok(Icmpv6Packet::Mld(MldPacket::MulticastListenerReport(msg))) => {
                            let group =
                                std::net::Ipv6Addr::from(msg.body().group_addr.ipv6_bytes());
                            if let Err(err) = self.on_netstack_joined_multicast_group(group) {
                                warn!(
                                    "Netstack refused to join multicast group {:?}: {:?}",
                                    group, err
                                );
                            }
                            // Drop the packet
                            return false;
                        }
                        Ok(Icmpv6Packet::Mld(MldPacket::MulticastListenerDone(msg))) => {
                            let group =
                                std::net::Ipv6Addr::from(msg.body().group_addr.ipv6_bytes());
                            if let Err(err) = self.on_netstack_left_multicast_group(group) {
                                warn!(
                                    "Netstack refused to leave multicast group {:?}: {:?}",
                                    group, err
                                );
                            }
                            // Drop the packet
                            return false;
                        }
                        Ok(_) => {}
                        Err(err) => {
                            warn!("Unable to parse ICMPv6 packet from host: {:?}", err);
                        }
                    }
                }
                _ => {}
            },
            Err(err) => {
                warn!("Unable to parse IPv6 packet from host: {:?}", err);
                // Drop the packet
                return false;
            }
        }
        // Pass the packet along to OpenThread.
        true
    }
async fn intercept_from_host ( & self , mut packet_bytes : & [ u8 ] ) -> bool { match Ipv6Packet :: parse ( & mut packet_bytes , ( ) ) { Ok ( packet ) => match packet . proto ( ) { Ipv6Proto :: Icmpv6 => { let args = IcmpParseArgs :: new ( packet . src_ip ( ) , packet . dst_ip ( ) ) ; match Icmpv6Packet :: parse ( & mut packet_bytes , args ) { Ok ( Icmpv6Packet :: Mld ( MldPacket :: MulticastListenerReport ( msg ) ) ) => { let group = std :: net :: Ipv6Addr :: from ( msg . body ( ) . group_addr . ipv6_bytes ( ) ) ; if let Err ( err ) = self . on_netstack_joined_multicast_group ( group ) { warn ! ( " " group err ) ; } // Drop the packet return false ; } Ok ( Icmpv6Packet :: Mld ( MldPacket :: MulticastListenerDone ( msg ) ) ) => { let group = std :: net :: Ipv6Addr :: from ( msg . body ( ) . group_addr . ipv6_bytes ( ) ) ; if let Err ( err ) = self . on_netstack_left_multicast_group ( group ) { warn ! ( " " group err ) ; } // Drop the packet return false ; } Ok ( _ ) => { } Err ( err ) => { warn ! ( " " err ) ; } } } _ => { } } , Err ( err ) => { warn ! ( " " err ) ; // Drop the packet return false ; } } // Pass the packet along to OpenThread. true }
Processes the given IPv6 packet from the host and determines if it should
be forwarded or not.
Processes the given IPv6 packet from the host and determines if it should be forwarded or not .
&self
packet_bytes
&[u8]