summaryrefslogtreecommitdiffstats
path: root/third_party/rust/neqo-common/src/tos.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/neqo-common/src/tos.rs
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-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.rs27
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());
+ }
}