fn new(ip: &Ipv4PacketHeader, dlen: usize) -> RawIpv4PacketHeader {
        let size          = mem::size_of::<RawIpv4PacketHeader>();
        let length        = size + (ip.options.len() << 2) + dlen;
        let ihl           = 5 + ip.options.len() as u8;
        let flags_foffset = ((ip.flags as u16) << 13) | (ip.foffset & 0x1fff);
        let mut rh        = RawIpv4PacketHeader {
            vihl:          (ip.version << 4) | (ihl & 0x0f),
            dscp_ecn:      (ip.dscp << 2) | (ip.ecn & 0x03),
            length:        (length as u16).to_be(),
            ident:         ip.ident.to_be(),
            flags_foffset: flags_foffset.to_be(),
            ttl:           ip.ttl,
            protocol:      ip.protocol,
            checksum:      0,
            src:           ip.src.octets(),
            dst:           ip.dst.octets()
        };

        let mut sum = raw::utils::sum_type(&rh);
        sum = sum.wrapping_add(raw::utils::sum_slice(&ip.options));

        rh.checksum = raw::utils::sum_to_checksum(sum)
            .to_be();

        rh
    }
/// Create a new raw IPv4 packet header.
Create a new raw IPv4 packet header.
Create a new raw IPv4 packet header .
fn new(ip: &Ipv4PacketHeader, dlen: usize) -> RawIpv4PacketHeader {
        let size          = mem::size_of::<RawIpv4PacketHeader>();
        let length        = size + (ip.options.len() << 2) + dlen;
        let ihl           = 5 + ip.options.len() as u8;
        let flags_foffset = ((ip.flags as u16) << 13) | (ip.foffset & 0x1fff);
        let mut rh        = RawIpv4PacketHeader {
            vihl:          (ip.version << 4) | (ihl & 0x0f),
            dscp_ecn:      (ip.dscp << 2) | (ip.ecn & 0x03),
            length:        (length as u16).to_be(),
            ident:         ip.ident.to_be(),
            flags_foffset: flags_foffset.to_be(),
            ttl:           ip.ttl,
            protocol:      ip.protocol,
            checksum:      0,
            src:           ip.src.octets(),
            dst:           ip.dst.octets()
        };
        let mut sum = raw::utils::sum_type(&rh);
        sum = sum.wrapping_add(raw::utils::sum_slice(&ip.options));
        rh.checksum = raw::utils::sum_to_checksum(sum)
            .to_be();
        rh
    }
fn new ( ip : & Ipv4PacketHeader , dlen : usize ) -> RawIpv4PacketHeader { let size = mem :: size_of :: < RawIpv4PacketHeader > ( ) ; let length = size + ( ip . options . len ( ) << 2 ) + dlen ; let ihl = 5 + ip . options . len ( ) as u8 ; let flags_foffset = ( ( ip . flags as u16 ) << 13 ) | ( ip . foffset & 0x1fff ) ; let mut rh = RawIpv4PacketHeader { vihl : ( ip . version << 4 ) | ( ihl & 0x0f ) , dscp_ecn : ( ip . dscp << 2 ) | ( ip . ecn & 0x03 ) , length : ( length as u16 ) . to_be ( ) , ident : ip . ident . to_be ( ) , flags_foffset : flags_foffset . to_be ( ) , ttl : ip . ttl , protocol : ip . protocol , checksum : 0 , src : ip . src . octets ( ) , dst : ip . dst . octets ( ) } ; let mut sum = raw :: utils :: sum_type ( & rh ) ; sum = sum . wrapping_add ( raw :: utils :: sum_slice ( & ip . options ) ) ; rh . checksum = raw :: utils :: sum_to_checksum ( sum ) . to_be ( ) ; rh }
Create a new raw IPv4 packet header.
Create a new raw IPv4 packet header .
ip
&Ipv4PacketHeader
dlen
usize
ip
&Ipv4PacketHeader
dlen
usize