Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support en/decoding the accurate ECN transport param #1860

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8023,6 +8023,8 @@ pub struct TransportParams {
pub retry_source_connection_id: Option<ConnectionId<'static>>,
/// DATAGRAM frame extension parameter, if any.
pub max_datagram_frame_size: Option<u64>,
/// Whether accurate ECN support is enabled.
pub accurate_ecn_enabled: bool,
// pub preferred_address: ...,
}

Expand All @@ -8046,6 +8048,7 @@ impl Default for TransportParams {
initial_source_connection_id: None,
retry_source_connection_id: None,
max_datagram_frame_size: None,
accurate_ecn_enabled: false,
}
}
}
Expand Down Expand Up @@ -8196,6 +8199,10 @@ impl TransportParams {
tp.max_datagram_frame_size = Some(val.get_varint()?);
},

0x2051a5fa8648af => {
tp.accurate_ecn_enabled = true;
},

// Ignore unknown parameters.
_ => (),
}
Expand Down Expand Up @@ -8358,6 +8365,10 @@ impl TransportParams {
b.put_varint(max_datagram_frame_size)?;
}

if tp.accurate_ecn_enabled {
TransportParams::encode_param(&mut b, 0x2051a5fa8648af, 0)?;
}

let out_len = b.off();

Ok(&mut out[..out_len])
Expand Down Expand Up @@ -8952,12 +8963,13 @@ mod tests {
initial_source_connection_id: Some(b"woot woot".to_vec().into()),
retry_source_connection_id: Some(b"retry".to_vec().into()),
max_datagram_frame_size: Some(32),
accurate_ecn_enabled: true,
};

let mut raw_params = [42; 256];
let raw_params =
TransportParams::encode(&tp, true, &mut raw_params).unwrap();
assert_eq!(raw_params.len(), 94);
assert_eq!(raw_params.len(), 103);

let new_tp = TransportParams::decode(raw_params, false).unwrap();

Expand All @@ -8982,12 +8994,13 @@ mod tests {
initial_source_connection_id: Some(b"woot woot".to_vec().into()),
retry_source_connection_id: None,
max_datagram_frame_size: Some(32),
accurate_ecn_enabled: true,
};

let mut raw_params = [42; 256];
let raw_params =
TransportParams::encode(&tp, false, &mut raw_params).unwrap();
assert_eq!(raw_params.len(), 69);
assert_eq!(raw_params.len(), 78);

let new_tp = TransportParams::decode(raw_params, true).unwrap();

Expand Down