Struct aya::programs::SkMsg [−][src]
pub struct SkMsg { /* fields omitted */ }
Expand description
A program used to intercept messages sent with sendmsg()
/sendfile()
.
SkMsg
programs are attached to socket maps, and can be used inspect,
filter and redirect messages sent on sockets. See also SockMap
and
SockHash
.
Examples
use std::convert::{TryFrom, TryInto}; use std::io::Write; use std::net::TcpStream; use std::os::unix::io::AsRawFd; use aya::maps::SockHash; use aya::programs::SkMsg; let mut intercept_egress = SockHash::try_from(bpf.map_mut("INTERCEPT_EGRESS")?)?; let prog: &mut SkMsg = bpf.program_mut("intercept_egress_packet")?.try_into()?; prog.load()?; prog.attach(&intercept_egress)?; let mut client = TcpStream::connect("127.0.0.1:1234")?; intercept_egress.insert(1234, client.as_raw_fd(), 0)?; // the write will be intercepted client.write_all(b"foo")?;
Implementations
Loads the program inside the kernel.
See also Program::load
.
Trait Implementations
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.
Auto Trait Implementations
impl !RefUnwindSafe for SkMsg
impl !UnwindSafe for SkMsg