pub struct SendQueue(/* private fields */);
Implementations§
source§impl SendQueue
impl SendQueue
sourcepub fn new(memsize: u32) -> Result<Self, Error>
pub fn new(memsize: u32) -> Result<Self, Error>
Create a new SendQueue
object with a maximum capacity of memsize
.
The buffer size memsize
must be able to contain both packet headers and actual packet
contents.
pub fn maxlen(&self) -> u32
pub fn is_empty(&self) -> bool
pub fn len(&self) -> u32
sourcepub fn queue(&mut self, ts: Option<Duration>, buf: &[u8]) -> Result<(), Error>
pub fn queue(&mut self, ts: Option<Duration>, buf: &[u8]) -> Result<(), Error>
Add a packet to the queue.
The ts
argument only needs to be a Some()
value if the transmission mode will be
synchronous when calling SendQueue::transmit()
.
sourcepub fn queue_sg(
&mut self,
ts: Option<Duration>,
iov: &[IoSlice<'_>]
) -> Result<(), Error>
pub fn queue_sg( &mut self, ts: Option<Duration>, iov: &[IoSlice<'_>] ) -> Result<(), Error>
Add a (potentially) scattered packet to the queue.
use std::io::IoSlice;
use pcap::sendqueue::SendQueue;
let dstmac: [u8; 6] = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff];
let srcmac: [u8; 6] = [0, 0, 0, 0, 0, 0];
let ethtype: [u8; 2] = [0x12, 0x34];
let payload: [u8; 5] = [0x00, 0x01, 0x02, 0x03, 0x04];
let iov = [
IoSlice::new(&dstmac),
IoSlice::new(&srcmac),
IoSlice::new(ðtype),
IoSlice::new(&payload),
];
let mut sq = SendQueue::new(1024*1024).unwrap();
sq.queue_sg(None, &iov).unwrap();
sourcepub fn transmit(
&mut self,
dev: &mut Capture<Active>,
sync: SendSync
) -> Result<(), Error>
pub fn transmit( &mut self, dev: &mut Capture<Active>, sync: SendSync ) -> Result<(), Error>
Transmit the contents of the queue.
If entire queue was transmitted successfully the queue will be automatically reset.
If sync
is set to SendSync::On
the difference between packet header timestamps
will be used as a delay between sending each packet. If SendSync::Off
is used the packets
will be transmitted with no delay between packets.
pub fn reset(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for SendQueue
impl !Send for SendQueue
impl !Sync for SendQueue
impl Unpin for SendQueue
impl UnwindSafe for SendQueue
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