pub struct Queue<T> { /* private fields */ }
Expand description
Opaque struct Queue
: abstracts an NFLOG queue
Implementations§
Source§impl<T: Send> Queue<T>
impl<T: Send> Queue<T>
Sourcepub fn open(&mut self)
pub fn open(&mut self)
Opens a NFLOG handler
This function obtains a netfilter queue connection handle. When you are
finished with the handle returned by this function, you should destroy it
by calling close()
.
A new netlink connection is obtained internally
and associated with the queue connection handle returned.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Closes a NFLOG handler
This function closes the nfqueue handler and free associated resources.
Sourcepub fn bind(&self, pf: c_int) -> i32
pub fn bind(&self, pf: c_int) -> i32
Bind a nfqueue handler to a given protocol family
Binds the given queue connection handle to process packets belonging to
the given protocol family (ie. PF_INET
, PF_INET6
, etc).
Arguments
pf
- Protocol family (usuallyAF_INET
orAF_INET6
)
Remarks:
Requires root privileges
Sourcepub fn unbind(&self, pf: c_int) -> i32
pub fn unbind(&self, pf: c_int) -> i32
Unbinds the nfqueue handler from a protocol family
Unbinds the given nfqueue handle from processing packets belonging to the given protocol family.
Arguments
pf
- Protocol family (usuallyAF_INET
orAF_INET6
)
Remarks:
Requires root privileges
Sourcepub fn fd(&self) -> i32
pub fn fd(&self) -> i32
Returns the C file descriptor associated with the nfqueue handler
This function returns a file descriptor that can be used for communication over the netlink connection associated with the given queue connection handle.
Sourcepub fn create_queue(&mut self, num: u16, cb: fn(&Message, &mut T))
pub fn create_queue(&mut self, num: u16, cb: fn(&Message, &mut T))
create a new queue handler bind it to a queue number, and to a callback.
Creates a new queue handle, and returns it. The new queue is identified
by num
, and the callback specified by cb
will be called for each
enqueued packet.
Arguments
num
: the number of the queue to bind tocb
: callback function to call for each queued packet
Sourcepub fn destroy_queue(&mut self)
pub fn destroy_queue(&mut self)
Destroys a group handle
Removes the binding for the specified queue handle. This call also unbind from the nfqueue handler, so you don’t need to call any extra function.
Sourcepub fn set_mode(&self, mode: CopyMode, range: u32)
pub fn set_mode(&self, mode: CopyMode, range: u32)
Set the amount of packet data that nfqueue copies to userspace
Arguments:
mode
- The part of the packet that we are interested inrange
- Size of the packet that we want to get
mode
can be one of:
NFQNL_COPY_NONE
- do not copy any dataNFQNL_COPY_META
- copy only packet metadataNFQNL_COPY_PACKET
- copy entire packet
Sourcepub fn set_queuelen(&self, queuelen: u32)
pub fn set_queuelen(&self, queuelen: u32)
Set kernel queue maximum length parameter
Arguments:
queuelen
- The length of the queue
Sets the size of the queue in kernel. This fixes the maximum number of packets the kernel will store before internally before dropping upcoming packets