[][src]Function quiche::negotiate_version

pub fn negotiate_version(
    scid: &[u8],
    dcid: &[u8],
    out: &mut [u8]
) -> Result<usize>

Writes a version negotiation packet.

The scid and dcid parameters are the source connection ID and the destination connection ID extracted from the received client's Initial packet that advertises an unsupported version.


let (len, src) = socket.recv_from(&mut buf).unwrap();

let hdr =
    quiche::Header::from_slice(&mut buf[..len], quiche::MAX_CONN_ID_LEN)?;

if hdr.version != quiche::PROTOCOL_VERSION {
    let len = quiche::negotiate_version(&hdr.scid, &hdr.dcid, &mut out)?;
    socket.send_to(&out[..len], &src).unwrap();