Skip to content

Commit

Permalink
test: Use latest netlink-packet-route
Browse files Browse the repository at this point in the history
Signed-off-by: Gris Ge <fge@redhat.com>
  • Loading branch information
cathay4t committed Jan 10, 2024
1 parent ee9aa5d commit 0a84bcd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ smol_socket = ["netlink-sys/smol_socket"]
[dev-dependencies]
env_logger = "0.8.2"
tokio = { version = "1.0.1", default-features = false, features = ["macros", "rt-multi-thread"] }
netlink-packet-route = { version = "0.14.1" }
netlink-packet-route = { version = "0.18.1" }
netlink-packet-audit = { version = "0.5.0" }
async-std = {version = "1.9.0", features = ["attributes"]}

Expand All @@ -37,7 +37,7 @@ name = "dump_links"

[[example]]
name = "dump_links_async"
required-features = ["smol_socket"]
required-features = ["tokio_socket"]

[[example]]
name = "audit_netlink_events"
4 changes: 2 additions & 2 deletions examples/audit_netlink_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ async fn main() -> Result<(), String> {
// - `messages` is a channel receiver through which we receive messages that
// we have not sollicated, ie that are not response to a request we made.
// In this example, we'll receive the audit event through that channel.
let (conn, mut handle, mut messages) = new_connection(NETLINK_AUDIT)
.map_err(|e| {
let (conn, handle, mut messages) =
new_connection(NETLINK_AUDIT).map_err(|e| {
format!("Failed to create a new netlink connection: {e}")
})?;

Expand Down
10 changes: 5 additions & 5 deletions examples/dump_links.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT

use futures::StreamExt;
use netlink_packet_route::{
LinkMessage, NetlinkHeader, NetlinkMessage, RtnlMessage, NLM_F_DUMP,
NLM_F_REQUEST,
use netlink_packet_core::{
NetlinkHeader, NetlinkMessage, NLM_F_DUMP, NLM_F_REQUEST,
};
use netlink_packet_route::{link::LinkMessage, RouteNetlinkMessage};
use netlink_proto::{
new_connection,
sys::{protocols::NETLINK_ROUTE, SocketAddr},
Expand All @@ -14,7 +14,7 @@ use netlink_proto::{
async fn main() -> Result<(), String> {
// Create the netlink socket. Here, we won't use the channel that
// receives unsolicited messages.
let (conn, mut handle, _) = new_connection(NETLINK_ROUTE).map_err(|e| {
let (conn, handle, _) = new_connection(NETLINK_ROUTE).map_err(|e| {
format!("Failed to create a new netlink connection: {e}")
})?;

Expand All @@ -26,7 +26,7 @@ async fn main() -> Result<(), String> {
nl_hdr.flags = NLM_F_DUMP | NLM_F_REQUEST;
let request = NetlinkMessage::new(
nl_hdr,
RtnlMessage::GetLink(LinkMessage::default()).into(),
RouteNetlinkMessage::GetLink(LinkMessage::default()).into(),
);

// Send the request
Expand Down
12 changes: 6 additions & 6 deletions examples/dump_links_async.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// SPDX-License-Identifier: MIT

use futures::StreamExt;
use netlink_packet_route::{
LinkMessage, NetlinkHeader, NetlinkMessage, RtnlMessage, NLM_F_DUMP,
NLM_F_REQUEST,
use netlink_packet_core::{
NetlinkHeader, NetlinkMessage, NLM_F_DUMP, NLM_F_REQUEST,
};
use netlink_packet_route::{link::LinkMessage, RouteNetlinkMessage};
use netlink_proto::{
new_connection,
sys::{protocols::NETLINK_ROUTE, SocketAddr},
};

#[async_std::main]
#[tokio::main]
async fn main() -> Result<(), String> {
// Create the netlink socket. Here, we won't use the channel that
// receives unsolicited messages.
let (conn, mut handle, _) = new_connection(NETLINK_ROUTE).map_err(|e| {
let (conn, handle, _) = new_connection(NETLINK_ROUTE).map_err(|e| {
format!("Failed to create a new netlink connection: {}", e)
})?;

Expand All @@ -27,7 +27,7 @@ async fn main() -> Result<(), String> {
nl_hdr.flags = NLM_F_DUMP | NLM_F_REQUEST;
let request = NetlinkMessage::new(
nl_hdr,
RtnlMessage::GetLink(LinkMessage::default()).into(),
RouteNetlinkMessage::GetLink(LinkMessage::default()).into(),
);

// Send the request
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@
//! ```rust,no_run
//! use futures::StreamExt;
//!
//! use netlink_packet_route::{
//! LinkMessage,
//! use netlink_packet_route::{link::LinkMessage, RouteNetlinkMessage};
//! use netlink_packet_core::{
//! NetlinkHeader,
//! NetlinkMessage,
//! RtnlMessage,
//! NLM_F_DUMP,
//! NLM_F_REQUEST,
//! NLM_F_REQUEST, NLM_F_DUMP
//! };
//!
//! use netlink_proto::{
Expand All @@ -140,7 +138,7 @@
//!
//! let msg = NetlinkMessage::new(
//! nl_hdr,
//! RtnlMessage::GetLink(LinkMessage::default()).into(),
//! RouteNetlinkMessage::GetLink(LinkMessage::default()).into(),
//! );
//!
//! // Send the request
Expand Down

0 comments on commit 0a84bcd

Please sign in to comment.