Module util

Source
Expand description

§Utility Module for Network Operations

§Purpose

This file serves as the entry point for the util module. It organizes and publicly exports various networking utilities required by the xdp-socket library and potentially useful for applications using it.

§How it works

It declares the sub-modules (netlink, packet, router, xdp) using pub mod and mod statements. It then uses pub use to re-export the most important functions and structs from these sub-modules, creating a consolidated and easy-to-use public API for the util module.

§Main components

  • Module declarations: Brings the utility sub-modules into the crate’s scope.
  • Public re-exports (pub use): Exposes functionalities like route lookups, packet header creation, and netlink queries to the rest of the crate.

Re-exports§

pub use netlink::find_default_gateway;
pub use netlink::get_ipv4_address;
pub use netlink::get_ipv4_routes;
pub use netlink::get_neighbors;
pub use packet::write_udp_header_for;
pub use router::Ipv4Route;
pub use router::Neighbor;
pub use router::NextHop;
pub use router::Router;
pub use xdp_prog::OwnedXdpProg;
pub use xdp_prog::xdp_features;
pub use xdp_prog::xdp_attach_program;
pub use mac_by_ifindex::mac_by_ifindex;

Modules§

mac_by_ifindex
netlink
Low-Level Netlink Interface
packet
UDP Packet Header Construction
router
IPv4 Routing and Neighbor Table Cache
xdp_prog
XDP Program Loading and Feature Querying