pub struct Injector { /* private fields */ }Expand description
High-level packet injection handle.
Wraps AfPacketTx. TPACKET_V3 TX uses V1 frame-based semantics.
§Examples
let mut tx = netring::Injector::builder()
.interface("lo")
.build()
.unwrap();
if let Some(mut slot) = tx.allocate(64) {
slot.data_mut()[0..6].copy_from_slice(&[0xff; 6]);
slot.set_len(64);
slot.send();
}
tx.flush().unwrap();Implementations§
Source§impl Injector
impl Injector
Sourcepub fn builder() -> InjectorBuilder
pub fn builder() -> InjectorBuilder
Start building a new injector.
Sourcepub fn allocate(&mut self, len: usize) -> Option<TxSlot<'_>>
pub fn allocate(&mut self, len: usize) -> Option<TxSlot<'_>>
Allocate a TX frame. Returns None if the ring is full.
Sourcepub fn flush(&mut self) -> Result<usize, Error>
pub fn flush(&mut self) -> Result<usize, Error>
Flush all pending frames to the wire. Returns the count flushed.
Sourcepub fn into_inner(self) -> AfPacketTx
pub fn into_inner(self) -> AfPacketTx
Unwrap into the low-level AfPacketTx.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Injector
impl RefUnwindSafe for Injector
impl Send for Injector
impl !Sync for Injector
impl Unpin for Injector
impl UnsafeUnpin for Injector
impl UnwindSafe for Injector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more