---
name: "ipq_get_packet"
section: "3"
platform: "linux"
package: "iptables"
version: "1:1.8.13-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ipq_message_type"
---

# ipq\_get\_packet(3)

query queue messages

Part of [ipq\_message\_type(3)](/ipq_message_type/3.md).

## NAME

ipq\_message\_type, ipq\_get\_packet, ipq\_getmsgerr — query queue messages

## SYNOPSIS

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

**int ipq\_message\_type(const unsigned char \****buf***);**\
 **ipq\_packet\_msg\_t \*ipq\_get\_packet(const unsigned char \****buf***);**\
 **int ipq\_get\_msgerr(const unsigned char \****buf***);**

## DESCRIPTION

The **ipq\_message\_type** function returns the type of queue message returned to userspace via **ipq\_read**.

**ipq\_message\_type** should always be called following a successful call to **ipq\_read** to determine whether the message is a packet message or an error message. The *buf* parameter should be the same data obtained from the previous call to **ipq\_read**.

**ipq\_message\_type** will return one of the following values:

- **NLMSG\_ERROR**

  An error message generated by the Netlink transport.

- **IPQM\_PACKET**

  A packet message containing packet metadata and optional packet payload data.

The **ipq\_get\_packet** function should be called if **ipq\_message\_type** returns **IPQM\_PACKET**. The *buf* parameter should point to the same data used for the call to **ipq\_message\_type**. The pointer returned by **ipq\_get\_packet** points to a packet message, which is declared as follows:

```
typedef struct ipq_packet_msg {
	unsigned long packet_id;        /* ID of queued packet */
	unsigned long mark;             /* Netfilter mark value */
	long timestamp_sec;             /* Packet arrival time (seconds) */
	long timestamp_usec;            /* Packet arrvial time (+useconds) */
	unsigned int hook;              /* Netfilter hook we rode in on */
	char indev_name[IFNAMSIZ];      /* Name of incoming interface */
	char outdev_name[IFNAMSIZ];     /* Name of outgoing interface */
	unsigned short hw_protocol;     /* Hardware protocol (network order) */
	unsigned short hw_type;         /* Hardware type */
	unsigned char hw_addrlen;       /* Hardware address length */
	unsigned char hw_addr[8];       /* Hardware address */
	size_t data_len;                /* Length of packet data */
	unsigned char payload[0];       /* Optional packet data */
} ipq_packet_msg_t;
```

Each of these fields may be read by the application.  If the queue mode is **IPQ\_COPY\_PACKET** and the *data\_len* value is greater than zero, the packet payload contents may be accessed in the memory following the **ipq\_packet\_msg\_t** structure to a range of *data\_len.*

The *packet\_id* field contains a packet identifier to be used when calling **ipq\_set\_verdict**.

The **ipq\_get\_msgerr** function should be called if **ipq\_message\_type** returns **NLMSG\_ERROR.** The *buf* parameter should point to the same data used for the call to **ipq\_message\_type**. The value returned by **ipq\_get\_msgerr** is set by higher level kernel code and corresponds to standard **errno** values.

## BUGS

None known.

## AUTHOR

James Morris \<jmorris@intercode.com.au\>

## COPYRIGHT

Copyright (c) 2000-2001 Netfilter Core Team.

Distributed under the GNU General Public License.

## SEE ALSO

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