pub fn serialize_wks(address: Ipv4Addr, protocol: u8, ports: &[u16], buf: &mut Vec<u8>) {
    let len = match ports.iter().max() {
        Some(highest_port) => (*highest_port as usize) / 8 + 1,
        None => 0,
    };
    buf.reserve(5 + len);
    buf.extend_from_slice(&address.octets());
    buf.push(protocol);
    let start_index = buf.len();
    buf.extend(iter::repeat(0).take(len));
    for port in ports {
        let offset = (*port as usize) / 8;
        let mask = 1 << (port % 8);
        buf[start_index + offset] |= mask;
    }
}
/// Serializes a WKS record into the provided buffer.
Serializes a WKS record into the provided buffer.
Serializes a WKS record into the provided buffer .
pub fn serialize_wks(address: Ipv4Addr, protocol: u8, ports: &[u16], buf: &mut Vec<u8>) {
    let len = match ports.iter().max() {
        Some(highest_port) => (*highest_port as usize) / 8 + 1,
        None => 0,
    };
    buf.reserve(5 + len);
    buf.extend_from_slice(&address.octets());
    buf.push(protocol);
    let start_index = buf.len();
    buf.extend(iter::repeat(0).take(len));
    for port in ports {
        let offset = (*port as usize) / 8;
        let mask = 1 << (port % 8);
        buf[start_index + offset] |= mask;
    }
}
pub fn serialize_wks ( address : Ipv4Addr , protocol : u8 , ports : & [ u16 ] , buf : & mut Vec < u8 > ) { let len = match ports . iter ( ) . max ( ) { Some ( highest_port ) => ( * highest_port as usize ) / 8 + 1 , None => 0 , } ; buf . reserve ( 5 + len ) ; buf . extend_from_slice ( & address . octets ( ) ) ; buf . push ( protocol ) ; let start_index = buf . len ( ) ; buf . extend ( iter :: repeat ( 0 ) . take ( len ) ) ; for port in ports { let offset = ( * port as usize ) / 8 ; let mask = 1 << ( port % 8 ) ; buf [ start_index + offset ] |= mask ; } }
Serializes a WKS record into the provided buffer.
Serializes a WKS record into the provided buffer .
address
Ipv4Addr
protocol
u8
ports
&[u16]
buf
&mut Vec<u8>
address
Ipv4Addr
protocol
u8
ports
&[u16]
buf
&mut Vec<u8>