diff --git a/audit/Cargo.toml b/audit/Cargo.toml index 562f337a..039073f2 100644 --- a/audit/Cargo.toml +++ b/audit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "audit" -version = "0.4.0" +version = "0.5.0" # TODO: drop this comment - already bumped version for trait changes authors = ["Corentin Henry "] edition = "2018" @@ -14,8 +14,8 @@ description = "linux audit via netlink" [dependencies] futures = "0.3.11" thiserror = "1" -netlink-packet-audit = "0.2" -netlink-proto = { default-features = false, version = "0.7" } +netlink-packet-audit = "0.3" +netlink-proto = { default-features = false, version = "0.8" } [features] default = ["tokio_socket"] diff --git a/ethtool/Cargo.toml b/ethtool/Cargo.toml index 675a4c86..b5b9fb00 100644 --- a/ethtool/Cargo.toml +++ b/ethtool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethtool" -version = "0.1.0" +version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes authors = ["Gris Ge "] license = "MIT" edition = "2018" @@ -24,12 +24,12 @@ anyhow = "1.0.44" async-std = { version = "1.9.0", optional = true} byteorder = "1.4.3" futures = "0.3.17" -genetlink = { default-features = false, version = "0.1.0"} +genetlink = { default-features = false, version = "0.2.0"} log = "0.4.14" -netlink-packet-core = "0.2.4" -netlink-packet-generic = "0.1.0" +netlink-packet-core = "0.3.0" +netlink-packet-generic = "0.2.0" netlink-packet-utils = "0.4.1" -netlink-proto = { default-features = false, version = "0.7.0" } +netlink-proto = { default-features = false, version = "0.8.0" } netlink-sys = "0.7.0" thiserror = "1.0.29" tokio = { version = "1.0.1", features = ["rt"], optional = true} diff --git a/genetlink/Cargo.toml b/genetlink/Cargo.toml index 2e15b8c2..52d9126e 100644 --- a/genetlink/Cargo.toml +++ b/genetlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "genetlink" -version = "0.1.0" +version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes authors = ["Leo "] edition = "2018" homepage = "https://github.com/little-dude/netlink" @@ -17,12 +17,12 @@ smol_socket = ["netlink-proto/smol_socket","netlink-proto/workaround-audit-bug", [dependencies] futures = "0.3.16" -netlink-packet-generic = "0.1.0" -netlink-proto = { default-features = false, version = "0.7.0" } +netlink-packet-generic = "0.2.0" +netlink-proto = { default-features = false, version = "0.8.0" } tokio = { version = "1.9.0", features = ["rt"], optional = true } async-std = { version = "1.9.0", optional = true } netlink-packet-utils = "0.4.1" -netlink-packet-core = "0.2.4" +netlink-packet-core = "0.3.0" thiserror = "1.0.26" [dev-dependencies] diff --git a/genetlink/src/message.rs b/genetlink/src/message.rs index 7cc0fcc2..defd5ff8 100644 --- a/genetlink/src/message.rs +++ b/genetlink/src/message.rs @@ -107,7 +107,7 @@ where } } -impl NetlinkSerializable for RawGenlMessage { +impl NetlinkSerializable for RawGenlMessage { fn message_type(&self) -> u16 { self.family_id } @@ -121,7 +121,7 @@ impl NetlinkSerializable for RawGenlMessage { } } -impl NetlinkDeserializable for RawGenlMessage { +impl NetlinkDeserializable for RawGenlMessage { type Error = DecodeError; fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result { let buffer = GenlBuffer::new_checked(payload)?; diff --git a/netlink-packet-audit/Cargo.toml b/netlink-packet-audit/Cargo.toml index 245c50e3..e87487f2 100644 --- a/netlink-packet-audit/Cargo.toml +++ b/netlink-packet-audit/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Corentin Henry "] name = "netlink-packet-audit" -version = "0.2.2" +version = "0.3.0" # TODO: drop this comment - already bumped version for trait changes edition = "2018" homepage = "https://github.com/little-dude/netlink" @@ -14,7 +14,7 @@ description = "netlink packet types" [dependencies] anyhow = "1.0.31" byteorder = "1.3.2" -netlink-packet-core = "0.2" +netlink-packet-core = "0.3" netlink-packet-utils = ">= 0.3, <0.5" [dev-dependencies] diff --git a/netlink-packet-audit/fuzz/Cargo.toml b/netlink-packet-audit/fuzz/Cargo.toml index 04067f92..5d2573d9 100644 --- a/netlink-packet-audit/fuzz/Cargo.toml +++ b/netlink-packet-audit/fuzz/Cargo.toml @@ -9,8 +9,8 @@ edition = "2018" cargo-fuzz = true [dependencies] -netlink-packet-audit = "0.2" -netlink-packet-core = "0.2" +netlink-packet-audit = "0.3" +netlink-packet-core = "0.3" libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } [[bin]] diff --git a/netlink-packet-audit/src/message.rs b/netlink-packet-audit/src/message.rs index 73dd345b..4a13b921 100644 --- a/netlink-packet-audit/src/message.rs +++ b/netlink-packet-audit/src/message.rs @@ -106,7 +106,7 @@ impl Emitable for AuditMessage { } } -impl NetlinkSerializable for AuditMessage { +impl NetlinkSerializable for AuditMessage { fn message_type(&self) -> u16 { self.message_type() } @@ -120,7 +120,7 @@ impl NetlinkSerializable for AuditMessage { } } -impl NetlinkDeserializable for AuditMessage { +impl NetlinkDeserializable for AuditMessage { type Error = DecodeError; fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result { match AuditBuffer::new_checked(payload) { diff --git a/netlink-packet-core/Cargo.toml b/netlink-packet-core/Cargo.toml index f46fb4fc..ccca7e14 100644 --- a/netlink-packet-core/Cargo.toml +++ b/netlink-packet-core/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Corentin Henry "] name = "netlink-packet-core" -version = "0.2.4" +version = "0.3.0" # TODO: drop this comment - already bumped version for trait changes edition = "2018" homepage = "https://github.com/little-dude/netlink" @@ -18,4 +18,4 @@ libc = "0.2.66" netlink-packet-utils = ">=0.3, <0.5" [dev-dependencies] -netlink-packet-route = "0.8" +netlink-packet-route = "0.9" diff --git a/netlink-packet-core/examples/protocol.rs b/netlink-packet-core/examples/protocol.rs index 7c092e0b..59dc1a6d 100644 --- a/netlink-packet-core/examples/protocol.rs +++ b/netlink-packet-core/examples/protocol.rs @@ -44,7 +44,7 @@ impl fmt::Display for DeserializeError { } // NetlinkDeserializable implementation -impl NetlinkDeserializable for PingPongMessage { +impl NetlinkDeserializable for PingPongMessage { type Error = DeserializeError; fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result { @@ -59,7 +59,7 @@ impl NetlinkDeserializable for PingPongMessage { } // NetlinkSerializable implementation -impl NetlinkSerializable for PingPongMessage { +impl NetlinkSerializable for PingPongMessage { fn message_type(&self) -> u16 { match self { PingPongMessage::Ping(_) => PING_MESSAGE, diff --git a/netlink-packet-core/src/lib.rs b/netlink-packet-core/src/lib.rs index 7e724829..5faed295 100644 --- a/netlink-packet-core/src/lib.rs +++ b/netlink-packet-core/src/lib.rs @@ -156,7 +156,7 @@ //! } //! //! // NetlinkDeserializable implementation -//! impl NetlinkDeserializable for PingPongMessage { +//! impl NetlinkDeserializable for PingPongMessage { //! type Error = DeserializeError; //! //! fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result { @@ -171,7 +171,7 @@ //! } //! //! // NetlinkSerializable implementation -//! impl NetlinkSerializable for PingPongMessage { +//! impl NetlinkSerializable for PingPongMessage { //! fn message_type(&self) -> u16 { //! match self { //! PingPongMessage::Ping(_) => PING_MESSAGE, diff --git a/netlink-packet-core/src/message.rs b/netlink-packet-core/src/message.rs index 497ca0c2..62076241 100644 --- a/netlink-packet-core/src/message.rs +++ b/netlink-packet-core/src/message.rs @@ -45,7 +45,7 @@ where impl NetlinkMessage where - I: NetlinkDeserializable + Debug + PartialEq + Eq + Clone, + I: NetlinkDeserializable + Debug + PartialEq + Eq + Clone, { /// Parse the given buffer as a netlink message pub fn deserialize(buffer: &[u8]) -> Result { @@ -56,7 +56,7 @@ where impl NetlinkMessage where - I: NetlinkSerializable + Debug + PartialEq + Eq + Clone, + I: NetlinkSerializable + Debug + PartialEq + Eq + Clone, { /// Return the length of this message in bytes pub fn buffer_len(&self) -> usize { @@ -92,7 +92,7 @@ where impl<'buffer, B, I> Parseable> for NetlinkMessage where B: AsRef<[u8]> + 'buffer, - I: Debug + PartialEq + Eq + Clone + NetlinkDeserializable, + I: Debug + PartialEq + Eq + Clone + NetlinkDeserializable, { fn parse(buf: &NetlinkBuffer<&'buffer B>) -> Result { use self::NetlinkPayload::*; @@ -129,7 +129,7 @@ where impl Emitable for NetlinkMessage where - I: NetlinkSerializable + Debug + PartialEq + Eq + Clone, + I: NetlinkSerializable + Debug + PartialEq + Eq + Clone, { fn buffer_len(&self) -> usize { use self::NetlinkPayload::*; diff --git a/netlink-packet-core/src/payload.rs b/netlink-packet-core/src/payload.rs index 499488b8..40f6f8fe 100644 --- a/netlink-packet-core/src/payload.rs +++ b/netlink-packet-core/src/payload.rs @@ -28,7 +28,7 @@ where impl NetlinkPayload where - I: NetlinkSerializable + Debug + PartialEq + Eq + Clone, + I: NetlinkSerializable + Debug + PartialEq + Eq + Clone, { pub fn message_type(&self) -> u16 { match self { diff --git a/netlink-packet-core/src/traits.rs b/netlink-packet-core/src/traits.rs index 368ba18a..0b9d0a7e 100644 --- a/netlink-packet-core/src/traits.rs +++ b/netlink-packet-core/src/traits.rs @@ -1,16 +1,15 @@ use crate::NetlinkHeader; use std::error::Error; -/// A `NetlinkDeserializable` type can be used to deserialize a buffer -/// into the target type `T` for which it is implemented. -pub trait NetlinkDeserializable { +/// A `NetlinkDeserializable` type can be deserialized from a buffer +pub trait NetlinkDeserializable: Sized { type Error: Error + Send + Sync + 'static; - /// Deserialize the given buffer into `T`. - fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result; + /// Deserialize the given buffer into `Self`. + fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result; } -pub trait NetlinkSerializable { +pub trait NetlinkSerializable { fn message_type(&self) -> u16; /// Return the length of the serialized data. diff --git a/netlink-packet-generic/Cargo.toml b/netlink-packet-generic/Cargo.toml index b92a5d95..39af2717 100644 --- a/netlink-packet-generic/Cargo.toml +++ b/netlink-packet-generic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "netlink-packet-generic" -version = "0.1.0" +version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes authors = ["Leo "] edition = "2018" homepage = "https://github.com/little-dude/netlink" @@ -14,7 +14,7 @@ description = "generic netlink packet types" anyhow = "1.0.39" libc = "0.2.86" byteorder = "1.4.2" -netlink-packet-core = "0.2" +netlink-packet-core = "0.3" netlink-packet-utils = "0.4" [dev-dependencies] diff --git a/netlink-packet-generic/src/message.rs b/netlink-packet-generic/src/message.rs index 3d0bfde6..6e2bcc69 100644 --- a/netlink-packet-generic/src/message.rs +++ b/netlink-packet-generic/src/message.rs @@ -146,7 +146,7 @@ where } } -impl NetlinkSerializable> for GenlMessage +impl NetlinkSerializable for GenlMessage where F: GenlFamily + Emitable + Clone + Debug + PartialEq + Eq, { @@ -163,7 +163,7 @@ where } } -impl<'a, F> NetlinkDeserializable> for GenlMessage +impl NetlinkDeserializable for GenlMessage where F: ParseableParametrized<[u8], GenlHeader> + Clone + Debug + PartialEq + Eq, { diff --git a/netlink-packet-route/Cargo.toml b/netlink-packet-route/Cargo.toml index 4e45b2ac..fa8e8ff7 100644 --- a/netlink-packet-route/Cargo.toml +++ b/netlink-packet-route/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Corentin Henry "] name = "netlink-packet-route" -version = "0.8.0" +version = "0.9.0" # TODO: drop this comment - already bumped version for trait changes edition = "2018" homepage = "https://github.com/little-dude/netlink" @@ -15,7 +15,7 @@ description = "netlink packet types" anyhow = "1.0.31" byteorder = "1.3.2" libc = "0.2.66" -netlink-packet-core = "0.2" +netlink-packet-core = "0.3" netlink-packet-utils = "0.4" bitflags = "1.2.1" diff --git a/netlink-packet-route/fuzz/Cargo.toml b/netlink-packet-route/fuzz/Cargo.toml index 741e1626..99888b57 100644 --- a/netlink-packet-route/fuzz/Cargo.toml +++ b/netlink-packet-route/fuzz/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" cargo-fuzz = true [dependencies] -netlink-packet-route = "0.7" +netlink-packet-route = "0.9" libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } [[bin]] diff --git a/netlink-packet-route/src/rtnl/message.rs b/netlink-packet-route/src/rtnl/message.rs index e1627bc3..46baf2ce 100644 --- a/netlink-packet-route/src/rtnl/message.rs +++ b/netlink-packet-route/src/rtnl/message.rs @@ -356,7 +356,7 @@ impl Emitable for RtnlMessage { } } -impl NetlinkSerializable for RtnlMessage { +impl NetlinkSerializable for RtnlMessage { fn message_type(&self) -> u16 { self.message_type() } @@ -370,7 +370,7 @@ impl NetlinkSerializable for RtnlMessage { } } -impl NetlinkDeserializable for RtnlMessage { +impl NetlinkDeserializable for RtnlMessage { type Error = DecodeError; fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result { let buf = RtnlMessageBuffer::new(payload); diff --git a/netlink-packet-sock-diag/Cargo.toml b/netlink-packet-sock-diag/Cargo.toml index e3d09cec..0e06a448 100644 --- a/netlink-packet-sock-diag/Cargo.toml +++ b/netlink-packet-sock-diag/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Flier Lu ", "Corentin Henry "] name = "netlink-packet-sock-diag" -version = "0.1.0" +version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes edition = "2018" homepage = "https://github.com/little-dude/netlink" @@ -14,7 +14,7 @@ description = "netlink packet types for the sock_diag subprotocol" [dependencies] anyhow = "1.0.32" byteorder = "1.3.4" -netlink-packet-core = "0.2" +netlink-packet-core = "0.3" netlink-packet-utils = ">= 0.3, <0.5" bitflags = "1.2.1" libc = "0.2.77" diff --git a/netlink-packet-sock-diag/src/message.rs b/netlink-packet-sock-diag/src/message.rs index 5a84b5aa..6ab52e86 100644 --- a/netlink-packet-sock-diag/src/message.rs +++ b/netlink-packet-sock-diag/src/message.rs @@ -64,7 +64,7 @@ impl Emitable for SockDiagMessage { } } -impl NetlinkSerializable for SockDiagMessage { +impl NetlinkSerializable for SockDiagMessage { fn message_type(&self) -> u16 { self.message_type() } @@ -78,7 +78,7 @@ impl NetlinkSerializable for SockDiagMessage { } } -impl NetlinkDeserializable for SockDiagMessage { +impl NetlinkDeserializable for SockDiagMessage { type Error = DecodeError; fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result { let buffer = SockDiagBuffer::new_checked(&payload)?; diff --git a/netlink-proto/Cargo.toml b/netlink-proto/Cargo.toml index 830f6698..c1582df0 100644 --- a/netlink-proto/Cargo.toml +++ b/netlink-proto/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Corentin Henry "] name = "netlink-proto" -version = "0.7.0" +version = "0.8.0" # TODO: drop this comment - already bumped version for trait changes edition = "2018" homepage = "https://github.com/little-dude/netlink" @@ -17,7 +17,7 @@ log = "0.4.8" futures = "0.3" tokio = { version = "1.0", default-features = false, features = ["io-util"] } tokio-util = { version = "0.6", default-features = false, features = ["codec"] } -netlink-packet-core = "0.2" +netlink-packet-core = "0.3" netlink-sys = { default-features = false, version = "0.7" } [features] @@ -29,8 +29,8 @@ workaround-audit-bug = [] [dev-dependencies] env_logger = "0.8.2" tokio = { version = "1.0.1", default-features = false, features = ["macros", "rt-multi-thread"] } -netlink-packet-route = "0.8" -netlink-packet-audit = "0.2" +netlink-packet-route = "0.9" +netlink-packet-audit = "0.3" async-std = {version = "1.9.0", features = ["attributes"]} [[example]] diff --git a/netlink-proto/src/codecs.rs b/netlink-proto/src/codecs.rs index d5c1af48..596806d4 100644 --- a/netlink-proto/src/codecs.rs +++ b/netlink-proto/src/codecs.rs @@ -31,7 +31,7 @@ impl NetlinkCodec { // See https://github.com/mozilla/libaudit-go/issues/24 impl Decoder for NetlinkCodec> where - T: NetlinkDeserializable + Debug + Eq + PartialEq + Clone, + T: NetlinkDeserializable + Debug + Eq + PartialEq + Clone, { type Item = NetlinkMessage; type Error = io::Error; @@ -141,7 +141,7 @@ where impl Encoder> for NetlinkCodec> where - T: Debug + Eq + PartialEq + Clone + NetlinkSerializable, + T: Debug + Eq + PartialEq + Clone + NetlinkSerializable, { type Error = io::Error; diff --git a/netlink-proto/src/connection.rs b/netlink-proto/src/connection.rs index 7406c198..3517d780 100644 --- a/netlink-proto/src/connection.rs +++ b/netlink-proto/src/connection.rs @@ -34,7 +34,7 @@ use crate::{ /// `Connection`, that in turn, sends them through the netlink socket. pub struct Connection where - T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, + T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, { socket: NetlinkFramed>>, @@ -52,7 +52,7 @@ where impl Connection where - T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable + Unpin, + T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable + Unpin, { pub(crate) fn new( requests_rx: UnboundedReceiver>, @@ -252,7 +252,7 @@ where impl Future for Connection where - T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable + Unpin, + T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable + Unpin, { type Output = (); diff --git a/netlink-proto/src/lib.rs b/netlink-proto/src/lib.rs index c9d4e774..d1c09786 100644 --- a/netlink-proto/src/lib.rs +++ b/netlink-proto/src/lib.rs @@ -231,8 +231,8 @@ where + PartialEq + Eq + Clone - + packet::NetlinkSerializable - + packet::NetlinkDeserializable + + packet::NetlinkSerializable + + packet::NetlinkDeserializable + Unpin, { let (requests_tx, requests_rx) = unbounded::>(); diff --git a/netlink-proto/src/protocol/protocol.rs b/netlink-proto/src/protocol/protocol.rs index eec9bc03..d53baa2e 100644 --- a/netlink-proto/src/protocol/protocol.rs +++ b/netlink-proto/src/protocol/protocol.rs @@ -32,7 +32,7 @@ impl RequestId { #[derive(Debug, Eq, PartialEq)] pub(crate) struct Response where - T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, + T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, M: Debug, { pub done: bool, @@ -49,7 +49,7 @@ struct PendingRequest { #[derive(Debug, Default)] pub(crate) struct Protocol where - T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, + T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, M: Debug, { /// Counter that is incremented for each message sent @@ -71,7 +71,7 @@ where impl Protocol where - T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, + T: Debug + Clone + PartialEq + Eq + NetlinkSerializable + NetlinkDeserializable, M: Clone + Debug, { pub fn new() -> Self { diff --git a/netlink-sys/Cargo.toml b/netlink-sys/Cargo.toml index c7b95662..579044eb 100644 --- a/netlink-sys/Cargo.toml +++ b/netlink-sys/Cargo.toml @@ -42,7 +42,7 @@ tokio_socket = ["tokio", "futures"] smol_socket = ["async-io","futures"] [dev-dependencies] -netlink-packet-audit = "0.2" +netlink-packet-audit = "0.3" [dev-dependencies.tokio] version = "1.0.1" diff --git a/rtnetlink/Cargo.toml b/rtnetlink/Cargo.toml index 0e6d3fa1..36ab9bf6 100644 --- a/rtnetlink/Cargo.toml +++ b/rtnetlink/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rtnetlink" -version = "0.8.1" +version = "0.9.0" # TODO: drop this comment - already bumped version for trait changes authors = ["Corentin Henry "] edition = "2018" @@ -21,8 +21,8 @@ smol_socket = ["netlink-proto/smol_socket", "async-std"] futures = "0.3.11" log = "0.4.8" thiserror = "1" -netlink-packet-route = "0.8" -netlink-proto = { default-features = false, version = "0.7" } +netlink-packet-route = "0.9" +netlink-proto = { default-features = false, version = "0.8" } nix = "0.22.0" tokio = { version = "1.0.1", features = ["rt"], optional = true} async-std = { version = "1.9.0", features = ["unstable"], optional = true}