in_pktinfo(2type)

NAME
in_pktinfo - information about the incoming packet

LIBRARY
Standard C library (libc, -lc)

SYNOPSIS
#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 */
    };

DESCRIPTION

  recvmsg(2)
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.

  sendmsg(2)
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.

STANDARDS
Linux.

HISTORY
Linux 2.2.

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