pub fn retry(
        version: Version,
        dcid: &[u8],
        scid: &[u8],
        token: &[u8],
        odcid: &[u8],
    ) -> Res<Vec<u8>> {
        let mut encoder = Encoder::default();
        encoder.encode_vec(1, odcid);
        let start = encoder.len();
        encoder.encode_byte(
            PACKET_BIT_LONG
                | PACKET_BIT_FIXED_QUIC
                | (PacketType::Retry.to_byte(version) << 4)
                | (random(1)[0] & 0xf),
        );
        encoder.encode_uint(4, version.as_u32());
        encoder.encode_vec(1, dcid);
        encoder.encode_vec(1, scid);
        debug_assert_ne!(token.len(), 0);
        encoder.encode(token);
        let tag = retry::use_aead(version, |aead| {
            let mut buf = vec![0; aead.expansion()];
            Ok(aead.encrypt(0, &encoder, &[], &mut buf)?.to_vec())
        })?;
        encoder.encode(&tag);
        let mut complete: Vec<u8> = encoder.into();
        Ok(complete.split_off(start))
    }
/// Make a retry packet.
/// As this is a simple packet, this is just an associated function.
/// As Retry is odd (it has to be constructed with leading bytes),
/// this returns a Vec<u8> rather than building on an encoder.
Make a retry packet.
As this is a simple packet, this is just an associated function.
As Retry is odd (it has to be constructed with leading bytes),
this returns a Vec rather than building on an encoder.
Make a retry packet . As this is a simple packet this is just an associated function . As Retry is odd ( it has to be constructed with leading bytes ) this returns a Vec rather than building on an encoder .
pub fn retry(
        version: Version,
        dcid: &[u8],
        scid: &[u8],
        token: &[u8],
        odcid: &[u8],
    ) -> Res<Vec<u8>> {
        let mut encoder = Encoder::default();
        encoder.encode_vec(1, odcid);
        let start = encoder.len();
        encoder.encode_byte(
            PACKET_BIT_LONG
                | PACKET_BIT_FIXED_QUIC
                | (PacketType::Retry.to_byte(version) << 4)
                | (random(1)[0] & 0xf),
        );
        encoder.encode_uint(4, version.as_u32());
        encoder.encode_vec(1, dcid);
        encoder.encode_vec(1, scid);
        debug_assert_ne!(token.len(), 0);
        encoder.encode(token);
        let tag = retry::use_aead(version, |aead| {
            let mut buf = vec![0; aead.expansion()];
            Ok(aead.encrypt(0, &encoder, &[], &mut buf)?.to_vec())
        })?;
        encoder.encode(&tag);
        let mut complete: Vec<u8> = encoder.into();
        Ok(complete.split_off(start))
    }
pub fn retry ( version : Version , dcid : & [ u8 ] , scid : & [ u8 ] , token : & [ u8 ] , odcid : & [ u8 ] , ) -> Res < Vec < u8 > > { let mut encoder = Encoder :: default ( ) ; encoder . encode_vec ( 1 , odcid ) ; let start = encoder . len ( ) ; encoder . encode_byte ( PACKET_BIT_LONG | PACKET_BIT_FIXED_QUIC | ( PacketType :: Retry . to_byte ( version ) << 4 ) | ( random ( 1 ) [ 0 ] & 0xf ) , ) ; encoder . encode_uint ( 4 , version . as_u32 ( ) ) ; encoder . encode_vec ( 1 , dcid ) ; encoder . encode_vec ( 1 , scid ) ; debug_assert_ne ! ( token len ( ) 0 ) ; encoder . encode ( token ) ; let tag = retry :: use_aead ( version , | aead | { let mut buf = vec ! [ 0 aead expansion ( ) ] ; Ok ( aead . encrypt ( 0 , & encoder , & [ ] , & mut buf ) ? . to_vec ( ) ) } ) ? ; encoder . encode ( & tag ) ; let mut complete : Vec < u8 > = encoder . into ( ) ; Ok ( complete . split_off ( start ) ) }
Make a retry packet.
Make a retry packet .
version
Version
dcid
&[u8]
scid
&[u8]
token
&[u8]
odcid
&[u8]