diff --git a/Cargo.toml b/Cargo.toml index 6cd0b97..bb949e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "ethtool" version = "0.2.8" authors = ["Gris Ge "] license = "MIT" -edition = "2018" +edition = "2021" description = "Linux Ethtool Communication Library" keywords = ["network"] categories = ["network-programming", "os"] @@ -20,16 +20,13 @@ tokio_socket = ["netlink-proto/tokio_socket", "tokio"] smol_socket = ["netlink-proto/smol_socket", "async-std"] [dependencies] -anyhow = "1.0.97" async-std = { version = "1.13.0", optional = true} -byteorder = "1.5.0" futures = "0.3.31" log = "0.4.26" -genetlink = { default-features = false, version = "0.2.5"} -netlink-packet-core = { version = "0.7.0"} -netlink-packet-generic = { version = "0.3.3" } -netlink-packet-utils = { version = "0.5.2" } -netlink-proto = { default-features = false, version = "0.11.5" } +genetlink = { default-features = false, version = "0.2.6"} +netlink-packet-core = { version = "0.8.0"} +netlink-packet-generic = { version = "0.4.0" } +netlink-proto = { default-features = false, version = "0.12.0" } netlink-sys = { version = "0.8.7" } thiserror = "1.0.69" tokio = { version = "1.44.0", features = ["rt"], optional = true} diff --git a/src/bitset_util.rs b/src/bitset_util.rs index 5e92216..a9644f7 100644 --- a/src/bitset_util.rs +++ b/src/bitset_util.rs @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; use log::warn; -use netlink_packet_utils::{ - nla::NlasIterator, - parsers::{parse_string, parse_u32}, - DecodeError, +use netlink_packet_core::{ + parse_string, parse_u32, DecodeError, ErrorContext, NlasIterator, }; const ETHTOOL_A_BITSET_BITS: u16 = 3; diff --git a/src/channel/attr.rs b/src/channel/attr.rs index d026c5f..797f22f 100644 --- a/src/channel/attr.rs +++ b/src/channel/attr.rs @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; -use byteorder::{ByteOrder, NativeEndian}; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::parse_u32, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + emit_u32, parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext, Nla, + NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED, }; use crate::{EthtoolAttr, EthtoolHeader}; @@ -75,7 +72,7 @@ impl Nla for EthtoolChannelAttr { | Self::RxCount(d) | Self::TxCount(d) | Self::OtherCount(d) - | Self::CombinedCount(d) => NativeEndian::write_u32(buffer, *d), + | Self::CombinedCount(d) => emit_u32(buffer, *d).unwrap(), Self::Other(ref attr) => attr.emit(buffer), } } diff --git a/src/coalesce/attr.rs b/src/coalesce/attr.rs index 8b82ae7..51384b8 100644 --- a/src/coalesce/attr.rs +++ b/src/coalesce/attr.rs @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; -use byteorder::{ByteOrder, NativeEndian}; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::{parse_u32, parse_u8}, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + emit_u32, parse_u32, parse_u8, DecodeError, DefaultNla, Emitable, + ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED, }; use crate::{EthtoolAttr, EthtoolHeader}; @@ -145,9 +142,7 @@ impl Nla for EthtoolCoalesceAttr { | Self::RxMaxFramesHigh(d) | Self::TxUsecsHigh(d) | Self::TxMaxFramesHigh(d) - | Self::RateSampleInterval(d) => { - NativeEndian::write_u32(buffer, *d) - } + | Self::RateSampleInterval(d) => emit_u32(buffer, *d).unwrap(), Self::UseAdaptiveRx(d) | Self::UseAdaptiveTx(d) => { buffer[0] = (*d).into() } diff --git a/src/feature/attr.rs b/src/feature/attr.rs index 89cd8cf..0b6cac6 100644 --- a/src/feature/attr.rs +++ b/src/feature/attr.rs @@ -1,11 +1,9 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; use log::warn; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::{parse_string, parse_u32}, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + parse_string, parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext, + Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED, }; use crate::{EthtoolAttr, EthtoolHeader}; diff --git a/src/fec/attr.rs b/src/fec/attr.rs index 6c33c9e..82cf543 100644 --- a/src/fec/attr.rs +++ b/src/fec/attr.rs @@ -1,11 +1,9 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; -use byteorder::{ByteOrder, NativeEndian}; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::{parse_u32, parse_u64, parse_u8}, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + emit_u64, parse_u32, parse_u64, parse_u8, DecodeError, DefaultNla, + Emitable, ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, + NLA_F_NESTED, }; use crate::{ @@ -237,7 +235,7 @@ impl Nla for EthtoolFecStat { match self { Self::Corrected(v) | Self::Uncorrected(v) - | Self::CorrectBits(v) => NativeEndian::write_u64(buffer, *v), + | Self::CorrectBits(v) => emit_u64(buffer, *v).unwrap(), Self::Other(attr) => attr.emit(buffer), } } diff --git a/src/handle.rs b/src/handle.rs index 8fa8a78..8021b59 100644 --- a/src/handle.rs +++ b/src/handle.rs @@ -2,11 +2,11 @@ use futures::{future::Either, FutureExt, Stream, StreamExt, TryStream}; use genetlink::GenetlinkHandle; +use netlink_packet_core::DecodeError; use netlink_packet_core::{ NetlinkMessage, NLM_F_ACK, NLM_F_DUMP, NLM_F_REQUEST, }; use netlink_packet_generic::GenlMessage; -use netlink_packet_utils::DecodeError; use crate::{ try_ethtool, EthtoolChannelHandle, EthtoolCoalesceHandle, EthtoolError, diff --git a/src/header.rs b/src/header.rs index 786f743..93944a6 100644 --- a/src/header.rs +++ b/src/header.rs @@ -2,12 +2,9 @@ use std::ffi::CString; -use anyhow::Context; -use byteorder::{ByteOrder, NativeEndian}; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer}, - parsers::{parse_string, parse_u32}, - DecodeError, Parseable, +use netlink_packet_core::{ + emit_u32, parse_string, parse_u32, DecodeError, DefaultNla, ErrorContext, + Nla, NlaBuffer, Parseable, }; const ALTIFNAMSIZ: usize = 128; @@ -50,7 +47,7 @@ impl Nla for EthtoolHeader { fn emit_value(&self, buffer: &mut [u8]) { match self { Self::DevIndex(value) | Self::Flags(value) => { - NativeEndian::write_u32(buffer, *value) + emit_u32(buffer, *value).unwrap() } Self::DevName(s) => { str_to_zero_ended_u8_array(s, buffer, ALTIFNAMSIZ) diff --git a/src/link_mode/attr.rs b/src/link_mode/attr.rs index 6110751..3cc19c3 100644 --- a/src/link_mode/attr.rs +++ b/src/link_mode/attr.rs @@ -1,10 +1,8 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::{parse_u32, parse_u8}, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + parse_u32, parse_u8, DecodeError, DefaultNla, Emitable, ErrorContext, Nla, + NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED, }; use crate::{ diff --git a/src/message.rs b/src/message.rs index 66a79a1..72ed7eb 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,9 +1,7 @@ // SPDX-License-Identifier: MIT +use netlink_packet_core::{DecodeError, Emitable, Nla, ParseableParametrized}; use netlink_packet_generic::{GenlFamily, GenlHeader}; -use netlink_packet_utils::{ - nla::Nla, DecodeError, Emitable, ParseableParametrized, -}; use crate::{ channel::{parse_channel_nlas, EthtoolChannelAttr}, diff --git a/src/pause/attr.rs b/src/pause/attr.rs index ddb9ac5..f18dfe5 100644 --- a/src/pause/attr.rs +++ b/src/pause/attr.rs @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; -use byteorder::{ByteOrder, NativeEndian}; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::{parse_u64, parse_u8}, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + emit_u64, parse_u64, parse_u8, DecodeError, DefaultNla, Emitable, + ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED, }; use crate::{EthtoolAttr, EthtoolHeader}; @@ -45,7 +42,7 @@ impl Nla for EthtoolPauseStatAttr { fn emit_value(&self, buffer: &mut [u8]) { match self { Self::Rx(value) | Self::Tx(value) => { - NativeEndian::write_u64(buffer, *value) + emit_u64(buffer, *value).unwrap() } Self::Other(ref attr) => attr.emit_value(buffer), } diff --git a/src/ring/attr.rs b/src/ring/attr.rs index 1de08d1..b8395ca 100644 --- a/src/ring/attr.rs +++ b/src/ring/attr.rs @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; -use byteorder::{ByteOrder, NativeEndian}; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::{parse_u32, parse_u8}, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + emit_u32, parse_u32, parse_u8, DecodeError, DefaultNla, Emitable, + ErrorContext, Nla, NlaBuffer, NlasIterator, Parseable, NLA_F_NESTED, }; use crate::{EthtoolAttr, EthtoolHeader}; @@ -93,7 +90,7 @@ impl Nla for EthtoolRingAttr { | Self::RxJumbo(d) | Self::RxBufLen(d) | Self::CqeSize(d) - | Self::Tx(d) => NativeEndian::write_u32(buffer, *d), + | Self::Tx(d) => emit_u32(buffer, *d).unwrap(), Self::TcpDataSplit(d) => buffer[0] = *d, Self::TxPush(d) => buffer[0] = *d as u8, Self::Other(ref attr) => attr.emit(buffer), diff --git a/src/tsinfo/attr.rs b/src/tsinfo/attr.rs index 1a18995..4fb58a2 100644 --- a/src/tsinfo/attr.rs +++ b/src/tsinfo/attr.rs @@ -1,10 +1,8 @@ // SPDX-License-Identifier: MIT -use anyhow::Context; -use netlink_packet_utils::{ - nla::{DefaultNla, Nla, NlaBuffer, NlasIterator, NLA_F_NESTED}, - parsers::parse_u32, - DecodeError, Emitable, Parseable, +use netlink_packet_core::{ + parse_u32, DecodeError, DefaultNla, Emitable, ErrorContext, Nla, NlaBuffer, + NlasIterator, Parseable, NLA_F_NESTED, }; use crate::{ diff --git a/tests/channels.rs b/tests/channels.rs index e62e3c4..37a6376 100644 --- a/tests/channels.rs +++ b/tests/channels.rs @@ -3,8 +3,8 @@ use ethtool::{ EthtoolAttr, EthtoolChannelAttr, EthtoolCmd, EthtoolHeader, EthtoolMessage, }; +use netlink_packet_core::{Emitable, Parseable, ParseableParametrized}; use netlink_packet_generic::{GenlBuffer, GenlHeader}; -use netlink_packet_utils::{Emitable, Parseable, ParseableParametrized}; #[test] fn test_channels_get_reply() {