diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /third_party/rust/neqo-common/src/tos.rs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/neqo-common/src/tos.rs')
-rw-r--r-- | third_party/rust/neqo-common/src/tos.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/third_party/rust/neqo-common/src/tos.rs b/third_party/rust/neqo-common/src/tos.rs index 533c5447e2..c7e5228dee 100644 --- a/third_party/rust/neqo-common/src/tos.rs +++ b/third_party/rust/neqo-common/src/tos.rs @@ -52,6 +52,16 @@ impl From<IpTos> for IpTosEcn { } } +impl IpTosEcn { + #[must_use] + pub fn is_ecn_marked(&self) -> bool { + match self { + IpTosEcn::Ect0 | IpTosEcn::Ect1 | IpTosEcn::Ce => true, + IpTosEcn::NotEct => false, + } + } +} + /// Diffserv Codepoints, mapped to the upper six bits of the TOS field. /// <https://www.iana.org/assignments/dscp-registry/dscp-registry.xhtml> #[derive(Copy, Clone, PartialEq, Eq, Enum, Default, Debug)] @@ -228,6 +238,11 @@ impl IpTos { pub fn set_dscp(&mut self, dscp: IpTosDscp) { self.0 = u8::from(IpTosEcn::from(*self)) | u8::from(dscp); } + + #[must_use] + pub fn is_ecn_marked(&self) -> bool { + IpTosEcn::from(*self).is_ecn_marked() + } } #[cfg(test)] @@ -346,4 +361,16 @@ mod tests { iptos.set_dscp(IpTosDscp::Le); assert_eq!(u8::from(iptos), 0b0000_0101); } + + #[test] + fn iptos_is_ecn_marked() { + let iptos: IpTos = (IpTosDscp::Af41, IpTosEcn::Ce).into(); + assert!(iptos.is_ecn_marked()); + } + + #[test] + fn iptosecn_is_ecn_marked() { + assert!(IpTosEcn::Ce.is_ecn_marked()); + assert!(!IpTosEcn::NotEct.is_ecn_marked()); + } } |