mirror of https://github.com/aya-rs/aya
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
472 B
Rust
20 lines
472 B
Rust
//! ```cargo
|
|
//! [dependencies]
|
|
//! aya = { path = "../../../../aya" }
|
|
//! ```
|
|
|
|
use aya::{
|
|
Bpf,
|
|
programs::{Xdp, XdpFlags},
|
|
};
|
|
use std::convert::TryInto;
|
|
|
|
fn main() {
|
|
println!("Loading XDP program");
|
|
let mut bpf = Bpf::load_file("pass.o").unwrap();
|
|
let dispatcher: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap();
|
|
dispatcher.load().unwrap();
|
|
dispatcher.attach("eth0", XdpFlags::default()).unwrap();
|
|
println!("Success...");
|
|
}
|