IPQ\_SET\_MODE(3) Linux Programmer's Manual IPQ\_SET\_MODE(3)

# [NAME](#NAME)

ipq\_set\_mode — set the ip\_queue queuing mode

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;linux/netfilter.h&gt;**  
**#include &lt;libipq.h&gt;**

**int ipq\_set\_mode(const struct ipq\_handle \*h, uint8\_t mode, size\_t range);**

# [DESCRIPTION](#DESCRIPTION)

The **ipq\_set\_mode** function sends a message to the kernel ip\_queue module, specifying whether packet metadata only, or packet payloads as well as metadata should be copied to userspace.

The *h* parameter is a context handle which must previously have been returned successfully from a call to **ipq\_create\_handle**.

The *mode* parameter must be one of:

[**IPQ\_COPY\_META**](#IPQ_COPY_META)

Copy only packet metadata to userspace.

[**IPQ\_COPY\_PACKET**](#IPQ_COPY_PACKET)

Copy packet metadata and packet payloads to userspace.

The *range* parameter is used to specify how many bytes of the payload to copy to userspace. It is only valid for **IPQ\_COPY\_PACKET** mode and is otherwise ignored. The maximum useful value for *range* is 65535 (greater values will be clamped to this by ip\_queue).

**ipq\_set\_mode** is usually used immediately following **ipq\_create\_handle** to enable the flow of packets to userspace.

Note that as the underlying Netlink messaging transport is connectionless, the ip\_queue module does not know that a userspace application is ready to communicate until it receives a message such as this.

# [RETURN VALUE](#RETURN_VALUE)

On failure, -1 is returned.  
On success, a non-zero positive value is returned.

# [ERRORS](#ERRORS)

On failure, a descriptive error message will be available via the **ipq\_errstr** function.

# [DIAGNOSTICS](#DIAGNOSTICS)

A relatively common failure may occur if the ip\_queue module is not loaded. In this case, the following code excerpt:

```
status = ipq_set_mode(h, IPQ_COPY_META, 0);
if (status < 0) {
	ipq_perror("myapp");
	ipq_destroy_handle(h);
	exit(1);
}
```

```

```

would generate the following output:

*myapp: Failed to send netlink message: Connection refused*

# [BUGS](#BUGS)

None known.

# [AUTHOR](#AUTHOR)

James Morris &lt;jmorris@intercode.com.au&gt;

# [COPYRIGHT](#COPYRIGHT)

Copyright (c) 2000-2001 Netfilter Core Team.

Distributed under the GNU General Public License.

# [SEE ALSO](#SEE_ALSO)

[**libipq**(3)](/man/os/iptables/libipq.3), [**iptables**(8)](/man/os/iptables/iptables.8).

16 October 2001 Linux iptables 1.2

---

Document: ipq_set_mode(3) from iptables 1.8.13-r5 (Chainguard OS)
Source: https://git.netfilter.org/iptables/
