---
name: "nfq_get_physindev_name"
section: "3"
platform: "linux"
package: "libnetfilter-queue-doc"
version: "1.0.5-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/nfq_get_msg_packet_hdr"
---

# nfq\_get\_physindev\_name(3)

Message parsing functions \[DEPRECATED\]

Part of [nfq\_get\_msg\_packet\_hdr(3)](/nfq_get_msg_packet_hdr/3.md).

## NAME

Parsing - Message parsing functions \[DEPRECATED\]

## SYNOPSIS

### Functions

struct nfqnl\_msg\_packet\_hdr \* **nfq\_get\_msg\_packet\_hdr** (struct nfq\_data \*nfad)\
 uint32\_t **nfq\_get\_nfmark** (struct nfq\_data \*nfad)\
 int **nfq\_get\_timestamp** (struct nfq\_data \*nfad, struct timeval \*tv)\
 uint32\_t **nfq\_get\_indev** (struct nfq\_data \*nfad)\
 uint32\_t **nfq\_get\_physindev** (struct nfq\_data \*nfad)\
 uint32\_t **nfq\_get\_outdev** (struct nfq\_data \*nfad)\
 uint32\_t **nfq\_get\_physoutdev** (struct nfq\_data \*nfad)\
 int **nfq\_get\_indev\_name** (struct nlif\_handle \*nlif\_handle, struct nfq\_data \*nfad, char \*name)\
 int **nfq\_get\_physindev\_name** (struct nlif\_handle \*nlif\_handle, struct nfq\_data \*nfad, char \*name)\
 int **nfq\_get\_outdev\_name** (struct nlif\_handle \*nlif\_handle, struct nfq\_data \*nfad, char \*name)\
 int **nfq\_get\_physoutdev\_name** (struct nlif\_handle \*nlif\_handle, struct nfq\_data \*nfad, char \*name)\
 struct nfqnl\_msg\_packet\_hw \* **nfq\_get\_packet\_hw** (struct nfq\_data \*nfad)\
 uint32\_t **nfq\_get\_skbinfo** (struct nfq\_data \*nfad)\
 int **nfq\_get\_uid** (struct nfq\_data \*nfad, uint32\_t \*uid)\
 int **nfq\_get\_gid** (struct nfq\_data \*nfad, uint32\_t \*gid)\
 int **nfq\_get\_secctx** (struct nfq\_data \*nfad, unsigned char \*\*secdata)\
 int **nfq\_get\_payload** (struct nfq\_data \*nfad, unsigned char \*\*data)\

## Detailed Description

## Function Documentation

### int nfq\_get\_gid (struct nfq\_data \* nfad, uint32\_t \* gid)

nfq\_get\_gid - get the GID of the user the packet belongs to

**Parameters**

*nfad* Netlink packet data handle passed to callback function \
 *gid* Set to GID on return

**Warning**

If the NFQA\_CFG\_F\_GSO flag is not set, then fragmented packets may be pushed into the queue. In this case, only one fragment will have the GID field set. To deal with this issue always set NFQA\_CFG\_F\_GSO.

**Returns**

1 if there is a GID available, 0 otherwise.

Definition at line **1277** of file **libnetfilter\_queue.c**.

### uint32\_t nfq\_get\_indev (struct nfq\_data \* nfad)

nfq\_get\_indev - get the interface that the packet was received through

**Parameters**

*nfad* Netlink packet data handle passed to callback function

**Returns**

The index of the device the queued packet was received via. If the returned index is 0, the packet was locally generated or the input interface is not known (ie. POSTROUTING?).

**Warning**

all nfq\_get\_dev() functions return 0 if not set, since linux only allows ifindex \>= 1, see net/core/dev.c:2600 (in 2.6.13.1)

Definition at line **1028** of file **libnetfilter\_queue.c**.

### int nfq\_get\_indev\_name (struct nlif\_handle \* nlif\_handle, struct nfq\_data \* nfad, char \* name)

nfq\_get\_indev\_name - get the name of the interface the packet was received through

**Parameters**

*nlif\_handle* pointer to a nlif interface resolving handle \
 *nfad* Netlink packet data handle passed to callback function \
 *name* pointer to the buffer to receive the interface name; not more than `IFNAMSIZ` bytes will be copied to it.

**Returns**

\-1 in case of error, \>0 if it succeed.

To use a nlif\_handle, You need first to call nlif\_open() and to open an handler. Don't forget to store the result as it will be used during all your program life:

```
        h = nlif_open();
        if (h == NULL) {
                perror('nlif_open');
                exit(EXIT_FAILURE);
        }
```

 Once the handler is open, you need to fetch the interface table at a whole via a call to nlif\_query.

```
        nlif_query(h);
```

 libnfnetlink is able to update the interface mapping when a new interface appears. To do so, you need to call nlif\_catch() on the handler after each interface related event. The simplest way to get and treat event is to run a select() or poll() against the nlif file descriptor. To get this file descriptor, you need to use nlif\_fd:

```
        if_fd = nlif_fd(h);
```

 Don't forget to close the handler when you don't need the feature anymore:

```
        nlif_close(h);
```

Definition at line **1116** of file **libnetfilter\_queue.c**.

### struct nfqnl\_msg\_packet\_hdr \* nfq\_get\_msg\_packet\_hdr (struct nfq\_data \* nfad)

nfqnl\_msg\_packet\_hdr - return the metaheader that wraps the packet

**Parameters**

*nfad* Netlink packet data handle passed to callback function

**Returns**

the netfilter queue netlink packet header for the given nfq\_data argument. Typically, the nfq\_data value is passed as the 3rd parameter to the callback function set by a call to **nfq\_create\_queue()**.

The nfqnl\_msg\_packet\_hdr structure is defined in libnetfilter\_queue.h as:

```
        struct nfqnl_msg_packet_hdr {
                uint32_t        packet_id;      // unique ID of packet in queue
                uint16_t        hw_protocol;    // hw protocol (network order)
                uint8_t         hook;           // netfilter hook
        } __attribute__ ((packed));
```

Definition at line **974** of file **libnetfilter\_queue.c**.

### uint32\_t nfq\_get\_nfmark (struct nfq\_data \* nfad)

nfq\_get\_nfmark - get the packet mark

**Parameters**

*nfad* Netlink packet data handle passed to callback function

**Returns**

the netfilter mark currently assigned to the given queued packet.

Definition at line **987** of file **libnetfilter\_queue.c**.

### uint32\_t nfq\_get\_outdev (struct nfq\_data \* nfad)

nfq\_get\_outdev - gets the interface that the packet will be routed out

**Parameters**

*nfad* Netlink packet data handle passed to callback function

**Returns**

The index of the device the queued packet will be sent out. If the returned index is 0, the packet is destined for localhost or the output interface is not yet known (ie. PREROUTING?).

Definition at line **1056** of file **libnetfilter\_queue.c**.

### int nfq\_get\_outdev\_name (struct nlif\_handle \* nlif\_handle, struct nfq\_data \* nfad, char \* name)

nfq\_get\_outdev\_name - get the name of the physical interface the packet will be sent to

**Parameters**

*nlif\_handle* pointer to a nlif interface resolving handle \
 *nfad* Netlink packet data handle passed to callback function \
 *name* pointer to the buffer to receive the interface name; not more than `IFNAMSIZ` bytes will be copied to it.

See **nfq\_get\_indev\_name()** documentation for nlif\_handle usage.

**Returns**

\-1 in case of error, \> 0 if it succeed.

Definition at line **1156** of file **libnetfilter\_queue.c**.

### struct nfqnl\_msg\_packet\_hw \* nfq\_get\_packet\_hw (struct nfq\_data \* nfad)

nfq\_get\_packet\_hw

get hardware address

**Parameters**

*nfad* Netlink packet data handle passed to callback function

Retrieves the hardware address associated with the given queued packet. For ethernet packets, the hardware address returned (if any) will be the MAC address of the packet source host. The destination MAC address is not known until after POSTROUTING and a successful ARP request, so cannot currently be retrieved.

The nfqnl\_msg\_packet\_hw structure is defined in libnetfilter\_queue.h as:

```
        struct nfqnl_msg_packet_hw {
                uint16_t        hw_addrlen;
                uint16_t        _pad;
                uint8_t hw_addr[8];
        } __attribute__ ((packed));
```

Definition at line **1207** of file **libnetfilter\_queue.c**.

### int nfq\_get\_payload (struct nfq\_data \* nfad, unsigned char \*\* data)

nfq\_get\_payload - get payload

**Parameters**

*nfad* Netlink packet data handle passed to callback function \
 *data* Pointer of pointer that will be pointed to the payload

Retrieve the payload for a queued packet. The actual amount and type of data retrieved by this function will depend on the mode set with the **nfq\_set\_mode()** function.

**Returns**

\-1 on error, otherwise \> 0.

Definition at line **1324** of file **libnetfilter\_queue.c**.

### uint32\_t nfq\_get\_physindev (struct nfq\_data \* nfad)

nfq\_get\_physindev - get the physical interface that the packet was received

**Parameters**

*nfad* Netlink packet data handle passed to callback function

**Returns**

The index of the physical device the queued packet was received via. If the returned index is 0, the packet was locally generated or the physical input interface is no longer known (ie. POSTROUTING?).

Definition at line **1042** of file **libnetfilter\_queue.c**.

### int nfq\_get\_physindev\_name (struct nlif\_handle \* nlif\_handle, struct nfq\_data \* nfad, char \* name)

nfq\_get\_physindev\_name - get the name of the physical interface the packet was received through

**Parameters**

*nlif\_handle* pointer to a nlif interface resolving handle \
 *nfad* Netlink packet data handle passed to callback function \
 *name* pointer to the buffer to receive the interface name; not more than `IFNAMSIZ` bytes will be copied to it.

See **nfq\_get\_indev\_name()** documentation for nlif\_handle usage.

**Returns**

\-1 in case of error, \> 0 if it succeed.

Definition at line **1136** of file **libnetfilter\_queue.c**.

### uint32\_t nfq\_get\_physoutdev (struct nfq\_data \* nfad)

nfq\_get\_physoutdev - get the physical interface that the packet output

**Parameters**

*nfad* Netlink packet data handle passed to callback function

The index of the physical device the queued packet will be sent out. If the returned index is 0, the packet is destined for localhost or the physical output interface is not yet known (ie. PREROUTING?).

**Returns**

The index of physical interface that the packet output will be routed out.

Definition at line **1072** of file **libnetfilter\_queue.c**.

### int nfq\_get\_physoutdev\_name (struct nlif\_handle \* nlif\_handle, struct nfq\_data \* nfad, char \* name)

nfq\_get\_physoutdev\_name - get the name of the interface the packet will be sent to

**Parameters**

*nlif\_handle* pointer to a nlif interface resolving handle \
 *nfad* Netlink packet data handle passed to callback function \
 *name* pointer to the buffer to receive the interface name; not more than `IFNAMSIZ` bytes will be copied to it.

See **nfq\_get\_indev\_name()** documentation for nlif\_handle usage.

**Returns**

\-1 in case of error, \> 0 if it succeed.

Definition at line **1177** of file **libnetfilter\_queue.c**.

### int nfq\_get\_secctx (struct nfq\_data \* nfad, unsigned char \*\* secdata)

nfq\_get\_secctx - get the security context for this packet

**Parameters**

*nfad* Netlink packet data handle passed to callback function \
 *secdata* data to write the security context to

**Warning**

If the NFQA\_CFG\_F\_GSO flag is not set, then fragmented packets may be pushed into the queue. In this case, only one fragment will have the SECCTX field set. To deal with this issue always set NFQA\_CFG\_F\_GSO.

**Returns**

\-1 on error, otherwise \> 0

Definition at line **1298** of file **libnetfilter\_queue.c**.

### uint32\_t nfq\_get\_skbinfo (struct nfq\_data \* nfad)

nfq\_get\_skbinfo - return the NFQA\_SKB\_INFO meta information

**Parameters**

*nfad* Netlink packet data handle passed to callback function

This can be used to obtain extra information about a packet by testing the returned integer for any of the following bit flags:

- •

  NFQA\_SKB\_CSUMNOTREADY packet header checksums will be computed by hardware later on, i.e. tcp/ip checksums in the packet must not be validated, application should pretend they are correct.

- •

  NFQA\_SKB\_GSO packet is an aggregated super-packet. It exceeds device mtu and will be (re-)split on transmit by hardware.

- •

  NFQA\_SKB\_CSUM\_NOTVERIFIED packet checksum was not yet verified by the kernel/hardware, for example because this is an incoming packet and the NIC does not perform checksum validation at hardware level.

**Returns**

the skbinfo value

**See also**

**[nfq\_set\_queue\_flags(3)](/nfq_set_queue_flags/3.md)**

**Definition at line 1236 of file libnetfilter\_queue.c.**

### int nfq\_get\_timestamp (struct nfq\_data \* nfad, struct timeval \* tv)

**nfq\_get\_timestamp - get the packet timestamp**

**Parameters**

*nfad* **Netlink packet data handle passed to callback function** \
 *tv* **structure to fill with timestamp info**

**Retrieves the received timestamp when the given queued packet.**

**Returns**

**0 on success, non-zero on failure.**

**Definition at line 1002 of file libnetfilter\_queue.c.**

### int nfq\_get\_uid (struct nfq\_data \* nfad, uint32\_t \* uid)

**nfq\_get\_uid - get the UID of the user the packet belongs to**

**Parameters**

*nfad* **Netlink packet data handle passed to callback function** \
 *uid* **Set to UID on return**

**Warning**

**If the NFQA\_CFG\_F\_GSO flag is not set, then fragmented packets may be pushed into the queue. In this case, only one fragment will have the UID field set. To deal with this issue always set NFQA\_CFG\_F\_GSO.**

**Returns**

**1 if there is a UID available, 0 otherwise.**

**Definition at line 1256 of file libnetfilter\_queue.c.**

## Author

**Generated automatically by Doxygen for libnetfilter\_queue from the source code.**
