/// Verify that an ICMP Parameter Problem packet was actually sent in
/// response to a packet with an unrecognized IPv6 extension header option.
///
/// `verify_icmp_for_unrecognized_ext_hdr_option` verifies that the next
/// frame in `net` is an ICMP packet with code set to `code`, and pointer
/// set to `pointer`.
Verify that an ICMP Parameter Problem packet was actually sent in
response to a packet with an unrecognized IPv6 extension header option.


Verify that an ICMP Parameter Problem packet was actually sent in response to a packet with an unrecognized IPv6 extension header option .
fn verify_icmp_for_unrecognized_ext_hdr_option(
        ctx: &mut Ctx<DummyEventDispatcher>,
        code: Icmpv6ParameterProblemCode,
        pointer: u32,
        offset: usize,
    ) {
        // Check the ICMP that bob attempted to send to alice
        let device_frames = ctx.dispatcher.frames_sent().clone();
        assert!(!device_frames.is_empty());
        let mut buffer = Buf::new(device_frames[offset].1.as_slice(), ..);
        let _frame =
            buffer.parse_with::<_, EthernetFrame<_>>(EthernetFrameLengthCheck::Check).unwrap();
        let packet = buffer.parse::<<Ipv6 as IpExtByteSlice<&[u8]>>::Packet>().unwrap();
        let (src_ip, dst_ip, proto, _) = packet.into_metadata();
        assert_eq!(dst_ip, DUMMY_CONFIG_V6.remote_ip.get());
        assert_eq!(src_ip, DUMMY_CONFIG_V6.local_ip.get());
        assert_eq!(proto, Ipv6Proto::Icmpv6);
        let icmp =
            buffer.parse_with::<_, Icmpv6Packet<_>>(IcmpParseArgs::new(src_ip, dst_ip)).unwrap();
        if let Icmpv6Packet::ParameterProblem(icmp) = icmp {
            assert_eq!(icmp.code(), code);
            assert_eq!(icmp.message().pointer(), pointer);
        } else {
            panic!("Expected ICMPv6 Parameter Problem: {:?}", icmp);
        }
    }
fn verify_icmp_for_unrecognized_ext_hdr_option ( ctx : & mut Ctx < DummyEventDispatcher > , code : Icmpv6ParameterProblemCode , pointer : u32 , offset : usize , ) { // Check the ICMP that bob attempted to send to alice let device_frames = ctx . dispatcher . frames_sent ( ) . clone ( ) ; assert ! ( device_frames is_empty ( ) ) ; let mut buffer = Buf :: new ( device_frames [ offset ] . 1 . as_slice ( ) , .. ) ; let _frame = buffer . parse_with :: < _ , EthernetFrame < _ > > ( EthernetFrameLengthCheck :: Check ) . unwrap ( ) ; let packet = buffer . parse :: < < Ipv6 as IpExtByteSlice < & [ u8 ] > > :: Packet > ( ) . unwrap ( ) ; let ( src_ip , dst_ip , proto , _ ) = packet . into_metadata ( ) ; assert_eq ! ( dst_ip DUMMY_CONFIG_V6 remote_ip get ( ) ) ; assert_eq ! ( src_ip DUMMY_CONFIG_V6 local_ip get ( ) ) ; assert_eq ! ( proto Ipv6Proto Icmpv6 ) ; let icmp = buffer . parse_with :: < _ , Icmpv6Packet < _ > > ( IcmpParseArgs :: new ( src_ip , dst_ip ) ) . unwrap ( ) ; if let Icmpv6Packet :: ParameterProblem ( icmp ) = icmp { assert_eq ! ( icmp code ( ) code ) ; assert_eq ! ( icmp message ( ) pointer ( ) pointer ) ; } else { panic ! ( " " icmp ) ; } }
Verify that an ICMP Parameter Problem packet was actually sent in
response to a packet with an unrecognized IPv6 extension header option.
Verify that an ICMP Parameter Problem packet was actually sent in response to a packet with an unrecognized IPv6 extension header option .
ctx
&mut Ctx<DummyEventDispatcher>
code
Icmpv6ParameterProblemCode
pointer
u32
offset
usize