in_pktinfo(2type) in_pktinfo(2type)

in_pktinfo - information about the incoming packet

Standard C library (libc-lc)

#include <netinet/in.h>
struct in_pktinfo {
    unsigned int    ipi_ifindex;   /* Interface index */
    struct in_addr  ipi_spec_dst;  /* Local address */
    struct in_addr  ipi_addr;      /* Header Destination address */
};

When returned by recvmsg(2), .ipi_ifindex is the unique index of the interface the packet was received on.

.ipi_spec_dst is the preferred source address for replies to the given packet.

.ipi_addr is the destination address in the packet header.

These addresses are usually the same, but can differ for broadcast or multicast packets. Depending on the configured routes, .ipi_spec_dst might belong to a different interface from the one that received the packet.

If IP_PKTINFO is passed to sendmsg(2) and .ipi_spec_dst is not zero, then it is used as the local source address, for the routing table lookup, and for setting up IP source route options.

When .ipi_ifindex is not zero, the primary local address of the interface specified by the index overwrites .ipi_spec_dst for the routing table lookup.

.ipi_addr is ignored.

Linux.

Linux 2.2.

IP_PKTINFO(2const), setsockopt(2), ip(7)

2025-11-26 Linux man-pages 6.17