ipq_read(3)

ipq_read3

Read queue messages from ip_queue and read into supplied buffer

Usage

#include <linux/netfilter.h>
#include <libipq.h>

ssize_t ipq_read(const struct ipq_handle *h, unsigned char *buf, size_t len, int timeout);

Overview

The ipq_read function reads a queue message from the kernel and copies it to the memory pointed to by buf to a maximum length of len.

The h parameter is a context handle which must previously have been returned successfully from a call to ipq_create_handle.

The caller is responsible for ensuring that the memory pointed to by buf is large enough to contain len bytes.

The timeout parameter may be used to set a timeout for the operation, specified in microseconds. This is implemented internally by the library via the select system call. A value of zero provides normal, backwards-compatible blocking behaviour with no timeout. A negative value causes the function to return immediately.

Data returned via buf should not be accessed directly. Use the ipq_message_type, ipq_get_packet, and ipq_get_msgerr functions to access the queue message in the buffer.

Return value

On failure, -1 is returned.
On success, a non-zero positive value is returned when no timeout value is specified.
On success with a timeout value specified, zero is returned if no data was available to read, or if a non-blocked signal was caught. In the latter case, the global errno value will be set to EINTR.

Errors

On error, a descriptive error message will be available via the ipq_errstr function.

Diagnostics

While the ipq_read function may return successfully, the queue message copied to the buffer may itself be an error message from a higher level kernel component. Use ipq_message_type to determine if it is an error message, and ipq_get_msgerr to access the value of the message.

Credits

Joost Remijn implemented the timeout feature, which appeared in the 1.2.4 release of iptables.

Releases

8 releases since Debian 3.0 (Woody); the text changed 4 times.

  1. 3.0–3.1
  2. 4.0
  3. 5.0
  4. 6.0
  5. 7–Arch

Bugs

None known.

Author

James Morris <[email protected]>

From iptables 1:1.8.13-1 in Arch Linux 2026-11-01. Also shipped by iptables-legacy. Parsed by carta from the page's man source.