| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 4 |
.\" |
| 5 |
.TH in_pktinfo 2type 2025-11-26 "Linux man-pages 6.18" |
| 6 |
.SH NAME |
| 7 |
in_pktinfo |
| 8 |
\- |
| 9 |
information about the incoming packet |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <netinet/in.h> |
| 16 |
.fi |
| 17 |
.P |
| 18 |
.EX |
| 19 |
struct in_pktinfo { |
| 20 |
unsigned int ipi_ifindex; /* Interface index */ |
| 21 |
struct in_addr ipi_spec_dst; /* Local address */ |
| 22 |
struct in_addr ipi_addr; /* Header Destination address */ |
| 23 |
}; |
| 24 |
.EE |
| 25 |
.SH DESCRIPTION |
| 26 |
.SS recvmsg(2) |
| 27 |
When returned by |
| 28 |
.BR recvmsg (2) , |
| 29 |
.I .ipi_ifindex |
| 30 |
is the unique index of the interface the packet was received on. |
| 31 |
.P |
| 32 |
.I .ipi_spec_dst |
| 33 |
is the preferred source address for replies to the given packet. |
| 34 |
.P |
| 35 |
.I .ipi_addr |
| 36 |
is the destination address in the packet header. |
| 37 |
.P |
| 38 |
These addresses are usually the same, |
| 39 |
but can differ for broadcast or multicast packets. |
| 40 |
Depending on the configured routes, |
| 41 |
.I .ipi_spec_dst |
| 42 |
might belong to a different interface from the one that received the packet. |
| 43 |
.SS sendmsg(2) |
| 44 |
If |
| 45 |
.B IP_PKTINFO |
| 46 |
is passed to |
| 47 |
.BR sendmsg (2) |
| 48 |
and |
| 49 |
.\" This field is grossly misnamed |
| 50 |
.I .ipi_spec_dst |
| 51 |
is not zero, |
| 52 |
then it is used as the local source address, |
| 53 |
for the routing table lookup, |
| 54 |
and for setting up IP source route options. |
| 55 |
.P |
| 56 |
When |
| 57 |
.I .ipi_ifindex |
| 58 |
is not zero, |
| 59 |
the primary local address of the interface specified by the index |
| 60 |
overwrites |
| 61 |
.I .ipi_spec_dst |
| 62 |
for the routing table lookup. |
| 63 |
.P |
| 64 |
.I .ipi_addr |
| 65 |
is ignored. |
| 66 |
.SH STANDARDS |
| 67 |
Linux. |
| 68 |
.SH HISTORY |
| 69 |
Linux 2.2. |
| 70 |
.\" Precisely: since Linux 2.1.68 |
| 71 |
.SH SEE ALSO |
| 72 |
.BR IP_PKTINFO (2const), |
| 73 |
.BR setsockopt (2), |
| 74 |
.BR ip (7) |