netlink_packet_route/
lib.rs

1// SPDX-License-Identifier: MIT
2
3//! The `netlink-packet-route` crate is designed to abstract Netlink route
4//! protocol(`rtnetlink`) packet into Rust data types. The goal of this crate is
5//! saving netlink user from reading Kernel Netlink codes.
6//!
7//! This crate grouped Netlink route protocol into these modules:
8//!  * `link`: NIC interface, similar to to `ip link` command.
9//!  * `address`: IP address, similar to `ip address` command.
10//!  * `route`: Route, similar to `ip route` command.
11//!  * `rule`: Route rule, similar to `ip rule` command.
12//!  * `tc`: Traffic control, similar to `tc` command.
13//!  * `neighbour`: Neighbour, similar to `ip neighbour` command.
14//!  * `neighbour_table`: Neighbour table, similar to `ip ntable` command.
15//!  * `nsid`: Namespace, similar to `ip netns` command.
16//!
17//! At the top level of this crate, we also provide:
18//!  * [AddressFamily]
19//!
20//! Normally, you should use [`rtnetlink`][rtnetlink_url] instead of using this
21//! crate directly.
22//!
23//! [rtnetlink_url]: https://docs.rs/rtnetlink
24
25pub mod address;
26mod address_family;
27pub mod link;
28pub mod neighbour;
29pub mod neighbour_table;
30pub mod nsid;
31pub mod prefix;
32pub mod route;
33pub mod rule;
34pub mod tc;
35
36mod message;
37#[cfg(test)]
38mod tests;
39
40pub(crate) mod ip;
41
42#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "android"))]
43mod address_family_linux;
44#[cfg(any(
45    target_os = "linux",
46    target_os = "fuchsia",
47    target_os = "android"
48))]
49pub use self::address_family_linux::AddressFamily;
50
51#[cfg(target_os = "freebsd")]
52mod address_family_freebsd;
53#[cfg(target_os = "freebsd")]
54pub use self::address_family_freebsd::AddressFamily;
55
56#[cfg(not(any(
57    target_os = "linux",
58    target_os = "fuchsia",
59    target_os = "freebsd",
60    target_os = "android",
61)))]
62mod address_family_fallback;
63#[cfg(not(any(
64    target_os = "linux",
65    target_os = "fuchsia",
66    target_os = "freebsd",
67    target_os = "android",
68)))]
69pub use self::address_family_fallback::AddressFamily;
70pub use self::{
71    ip::IpProtocol,
72    message::{RouteNetlinkMessage, RouteNetlinkMessageBuffer},
73};
74
75#[macro_use]
76extern crate netlink_packet_core;
77
78#[cfg(test)]
79#[macro_use]
80extern crate pretty_assertions;
81
82#[macro_use]
83extern crate bitflags;