Skip to content

Commit

Permalink
chore: deprecate IpTos in favor of Ipv4Tos (#2465)
Browse files Browse the repository at this point in the history
* chore: deprecate IpTos in favor of Ipv4Tos

* chore: allow deprecated in its macro

* try again

* refactor: allow(deprecated) in set/getsockopt_impl!()
  • Loading branch information
SteveLauC authored Aug 1, 2024
1 parent 25b437c commit 1e259be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/2465.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Socket option `IpTos` has been renamed to `Ipv4Tos`, the old symbol is deprecated since 0.30.0
15 changes: 15 additions & 0 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const TCP_CA_NAME_MAX: usize = 16;
/// `bool`, `SetUsize` for `usize`, etc.).
macro_rules! setsockopt_impl {
($name:ident, $level:expr, $flag:path, $ty:ty, $setter:ty) => {
#[allow(deprecated)] // to allow we have deprecated socket option
impl SetSockOpt for $name {
type Val = $ty;

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

Expand Down Expand Up @@ -404,6 +406,19 @@ sockopt_impl!(
);
#[cfg(any(linux_android, target_os = "freebsd"))]
#[cfg(feature = "net")]
sockopt_impl!(
#[deprecated(since = "0.30.0", note = "Use Ipv4Tos instead")]
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
/// Set or receive the Type-Of-Service (TOS) field that is
/// sent with every IP packet originating from this socket
IpTos,
Both,
libc::IPPROTO_IP,
libc::IP_TOS,
libc::c_int
);
#[cfg(any(linux_android, target_os = "freebsd"))]
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
/// Set or receive the Type-Of-Service (TOS) field that is
Expand Down

0 comments on commit 1e259be

Please sign in to comment.