fn build_ipv6_response(
    request: &Ipv6Packet,
    src_address: Ipv6Addr,
    data: Vec<u8>,
    hop_limit: Option<u8>,
) -> Vec<u8> {
    let mut response = vec![0; MutableIpv6Packet::minimum_packet_size() + data.len()];

    let mut packet = MutableIpv6Packet::new(&mut response)
        .expect("Could not construct IPv6 packet with vector as buffer");
    packet.populate(&Ipv6 {
        version: 6,
        traffic_class: 0,
        flow_label: 0,
        payload_length: data.len() as u16,
        next_header: IpNextHeaderProtocols::Icmpv6,
        hop_limit: hop_limit.unwrap_or(request.get_hop_limit() - 1),
        source: src_address,
        destination: request.get_source(),
        payload: data,
    });

    response
}
/// Build an IPv6 packet in response to the provided one
///
/// The generated response packet will have most of it's relevant data extracted from `request`
/// except for it's own source address which is provided via `src_address`.
/// It will also have the given `data` as it's paylaod.
Build an IPv6 packet in response to the provided one
The generated response packet will have most of it's relevant data extracted from `request`
except for it's own source address which is provided via `src_address`.
It will also have the given `data` as it's paylaod.
Build an IPv6 packet in response to the provided one The generated response packet will have most of it ' s relevant data extracted from ` request ` except for it ' s own source address which is provided via ` src_address ` . It will also have the given ` data ` as it ' s paylaod .
fn build_ipv6_response(
    request: &Ipv6Packet,
    src_address: Ipv6Addr,
    data: Vec<u8>,
    hop_limit: Option<u8>,
) -> Vec<u8> {
    let mut response = vec![0; MutableIpv6Packet::minimum_packet_size() + data.len()];
    let mut packet = MutableIpv6Packet::new(&mut response)
        .expect("Could not construct IPv6 packet with vector as buffer");
    packet.populate(&Ipv6 {
        version: 6,
        traffic_class: 0,
        flow_label: 0,
        payload_length: data.len() as u16,
        next_header: IpNextHeaderProtocols::Icmpv6,
        hop_limit: hop_limit.unwrap_or(request.get_hop_limit() - 1),
        source: src_address,
        destination: request.get_source(),
        payload: data,
    });
    response
}
fn build_ipv6_response ( request : & Ipv6Packet , src_address : Ipv6Addr , data : Vec < u8 > , hop_limit : Option < u8 > , ) -> Vec < u8 > { let mut response = vec ! [ 0 MutableIpv6Packet minimum_packet_size ( ) data len ( ) ] ; let mut packet = MutableIpv6Packet :: new ( & mut response ) . expect ( " " ) ; packet . populate ( & Ipv6 { version : 6 , traffic_class : 0 , flow_label : 0 , payload_length : data . len ( ) as u16 , next_header : IpNextHeaderProtocols :: Icmpv6 , hop_limit : hop_limit . unwrap_or ( request . get_hop_limit ( ) - 1 ) , source : src_address , destination : request . get_source ( ) , payload : data , } ) ; response }
Build an IPv6 packet in response to the provided one
The generated response packet will have most of it's relevant data extracted from `request`
except for it's own source address which is provided via `src_address`.
Build an IPv6 packet in response to the provided one The generated response packet will have most of it ' s relevant data extracted from ` request ` except for it ' s own source address which is provided via ` src_address ` .
request
&Ipv6Packet
src_address
Ipv6Addr
data
Vec<u8>
hop_limit
Option<u8>
request
&Ipv6Packet
src_address
Ipv6Addr
data
Vec<u8>
hop_limit
Option<u8>