diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/neqo-common/src/tos.rs | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 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()); + } } |