pub fn parse(packet: &EthernetPacket) -> Indicator {
        let mut transport = None;

        let link = Layers::Ethernet(Ethernet::parse(packet));
        let network = match packet.get_ethertype() {
            EtherTypes::Arp => match ArpPacket::new(packet.payload()) {
                Some(ref arp_packet) => Some(Layers::Arp(Arp::parse(arp_packet))),
                None => None,
            },
            EtherTypes::Ipv4 => match Ipv4Packet::new(packet.payload()) {
                Some(ref ipv4_packet) => {
                    let this_ipv4 = Ipv4::parse(ipv4_packet);
                    let src = this_ipv4.get_src();
                    let dst = this_ipv4.get_dst();
                    let this_ipv4 = Some(Layers::Ipv4(this_ipv4));
                    // Fragment
                    if ipv4_packet.get_flags() & Ipv4Flags::MoreFragments == 0
                        && ipv4_packet.get_fragment_offset() <= 0
                    {
                        transport = match ipv4_packet.get_next_level_protocol() {
                            IpNextHeaderProtocols::Tcp => {
                                match TcpPacket::new(ipv4_packet.payload()) {
                                    Some(ref tcp_packet) => {
                                        Some(Layers::Tcp(Tcp::parse(tcp_packet, src, dst)))
                                    }
                                    None => None,
                                }
                            }
                            IpNextHeaderProtocols::Udp => {
                                match UdpPacket::new(ipv4_packet.payload()) {
                                    Some(ref udp_packet) => {
                                        Some(Layers::Udp(Udp::parse(udp_packet, src, dst)))
                                    }
                                    None => None,
                                }
                            }
                            _ => None,
                        };
                    }

                    this_ipv4
                }
                None => None,
            },
            _ => None,
        };

        Indicator {
            link,
            network,
            transport,
        }
    }
/// Creates a `Indicator` by the given Ethernet packet.
Creates a `Indicator` by the given Ethernet packet.
Creates a ` Indicator ` by the given Ethernet packet .
pub fn parse(packet: &EthernetPacket) -> Indicator {
        let mut transport = None;
        let link = Layers::Ethernet(Ethernet::parse(packet));
        let network = match packet.get_ethertype() {
            EtherTypes::Arp => match ArpPacket::new(packet.payload()) {
                Some(ref arp_packet) => Some(Layers::Arp(Arp::parse(arp_packet))),
                None => None,
            },
            EtherTypes::Ipv4 => match Ipv4Packet::new(packet.payload()) {
                Some(ref ipv4_packet) => {
                    let this_ipv4 = Ipv4::parse(ipv4_packet);
                    let src = this_ipv4.get_src();
                    let dst = this_ipv4.get_dst();
                    let this_ipv4 = Some(Layers::Ipv4(this_ipv4));
                    // Fragment
                    if ipv4_packet.get_flags() & Ipv4Flags::MoreFragments == 0
                        && ipv4_packet.get_fragment_offset() <= 0
                    {
                        transport = match ipv4_packet.get_next_level_protocol() {
                            IpNextHeaderProtocols::Tcp => {
                                match TcpPacket::new(ipv4_packet.payload()) {
                                    Some(ref tcp_packet) => {
                                        Some(Layers::Tcp(Tcp::parse(tcp_packet, src, dst)))
                                    }
                                    None => None,
                                }
                            }
                            IpNextHeaderProtocols::Udp => {
                                match UdpPacket::new(ipv4_packet.payload()) {
                                    Some(ref udp_packet) => {
                                        Some(Layers::Udp(Udp::parse(udp_packet, src, dst)))
                                    }
                                    None => None,
                                }
                            }
                            _ => None,
                        };
                    }
                    this_ipv4
                }
                None => None,
            },
            _ => None,
        };
        Indicator {
            link,
            network,
            transport,
        }
    }
pub fn parse ( packet : & EthernetPacket ) -> Indicator { let mut transport = None ; let link = Layers :: Ethernet ( Ethernet :: parse ( packet ) ) ; let network = match packet . get_ethertype ( ) { EtherTypes :: Arp => match ArpPacket :: new ( packet . payload ( ) ) { Some ( ref arp_packet ) => Some ( Layers :: Arp ( Arp :: parse ( arp_packet ) ) ) , None => None , } , EtherTypes :: Ipv4 => match Ipv4Packet :: new ( packet . payload ( ) ) { Some ( ref ipv4_packet ) => { let this_ipv4 = Ipv4 :: parse ( ipv4_packet ) ; let src = this_ipv4 . get_src ( ) ; let dst = this_ipv4 . get_dst ( ) ; let this_ipv4 = Some ( Layers :: Ipv4 ( this_ipv4 ) ) ; // Fragment if ipv4_packet . get_flags ( ) & Ipv4Flags :: MoreFragments == 0 && ipv4_packet . get_fragment_offset ( ) <= 0 { transport = match ipv4_packet . get_next_level_protocol ( ) { IpNextHeaderProtocols :: Tcp => { match TcpPacket :: new ( ipv4_packet . payload ( ) ) { Some ( ref tcp_packet ) => { Some ( Layers :: Tcp ( Tcp :: parse ( tcp_packet , src , dst ) ) ) } None => None , } } IpNextHeaderProtocols :: Udp => { match UdpPacket :: new ( ipv4_packet . payload ( ) ) { Some ( ref udp_packet ) => { Some ( Layers :: Udp ( Udp :: parse ( udp_packet , src , dst ) ) ) } None => None , } } _ => None , } ; } this_ipv4 } None => None , } , _ => None , } ; Indicator { link , network , transport , } }
Creates a `Indicator` by the given Ethernet packet.
Creates a ` Indicator ` by the given Ethernet packet .
packet
&EthernetPacket