Skip to content

Commit 1e259be

Browse files
authored
chore: deprecate IpTos in favor of Ipv4Tos (#2465)
* chore: deprecate IpTos in favor of Ipv4Tos * chore: allow deprecated in its macro * try again * refactor: allow(deprecated) in set/getsockopt_impl!()
1 parent 25b437c commit 1e259be

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

changelog/2465.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Socket option `IpTos` has been renamed to `Ipv4Tos`, the old symbol is deprecated since 0.30.0

src/sys/socket/sockopt.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const TCP_CA_NAME_MAX: usize = 16;
4444
/// `bool`, `SetUsize` for `usize`, etc.).
4545
macro_rules! setsockopt_impl {
4646
($name:ident, $level:expr, $flag:path, $ty:ty, $setter:ty) => {
47+
#[allow(deprecated)] // to allow we have deprecated socket option
4748
impl SetSockOpt for $name {
4849
type Val = $ty;
4950

@@ -89,6 +90,7 @@ macro_rules! setsockopt_impl {
8990
/// `bool`, `GetUsize` for `usize`, etc.).
9091
macro_rules! getsockopt_impl {
9192
($name:ident, $level:expr, $flag:path, $ty:ty, $getter:ty) => {
93+
#[allow(deprecated)] // to allow we have deprecated socket option
9294
impl GetSockOpt for $name {
9395
type Val = $ty;
9496

@@ -404,6 +406,19 @@ sockopt_impl!(
404406
);
405407
#[cfg(any(linux_android, target_os = "freebsd"))]
406408
#[cfg(feature = "net")]
409+
sockopt_impl!(
410+
#[deprecated(since = "0.30.0", note = "Use Ipv4Tos instead")]
411+
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
412+
/// Set or receive the Type-Of-Service (TOS) field that is
413+
/// sent with every IP packet originating from this socket
414+
IpTos,
415+
Both,
416+
libc::IPPROTO_IP,
417+
libc::IP_TOS,
418+
libc::c_int
419+
);
420+
#[cfg(any(linux_android, target_os = "freebsd"))]
421+
#[cfg(feature = "net")]
407422
sockopt_impl!(
408423
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
409424
/// Set or receive the Type-Of-Service (TOS) field that is

0 commit comments

Comments
 (0)