From: Alejandro Colomar Date: Mon, 24 Nov 2025 18:14:05 +0000 (+0100) Subject: man/man2const/{IPPROTO_IP,IP_PKTINFO}.2const: Split IP_PKTINFO from IPPROTO_IP(2const) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=098f8ce67fc023f322a224633a00d88d0616f3ed;p=thirdparty%2Fman-pages.git man/man2const/{IPPROTO_IP,IP_PKTINFO}.2const: Split IP_PKTINFO from IPPROTO_IP(2const) Signed-off-by: Alejandro Colomar --- diff --git a/man/man2const/IPPROTO_IP.2const b/man/man2const/IPPROTO_IP.2const index 0f969dc0a..1cac661ff 100644 --- a/man/man2const/IPPROTO_IP.2const +++ b/man/man2const/IPPROTO_IP.2const @@ -104,74 +104,8 @@ fail with the error .BR IP_OPTIONS (2const) .TQ .BR IP_PASSSEC (2const) -.TP -.BR IP_PKTINFO " (since Linux 2.2)" -.\" Precisely: since Linux 2.1.68 -Pass an -.B IP_PKTINFO -ancillary message that contains a -.I pktinfo -structure that supplies some information about the incoming packet. -This works only for datagram oriented sockets. -The argument is a flag that tells the socket whether the -.B IP_PKTINFO -message should be passed or not. -The message itself can be sent/retrieved -only as a control message with a packet using -.BR recvmsg (2) -or -.BR sendmsg (2). -.IP -.in +4n -.EX -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 */ -}; -.EE -.in -.IP -When returned by -.BR recvmsg (2) , -.I ipi_ifindex -is the unique index of the interface the packet was received on. -.I ipi_spec_dst -is the preferred source address for replies to the given packet, -and -.I 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, -.I ipi_spec_dst -might belong to a different interface from the one that received the packet. -.IP -If -.B IP_PKTINFO -is passed to -.BR sendmsg (2) -and -.\" This field is grossly misnamed -.I 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 -.I ipi_ifindex -is not zero, -the primary local address of the interface specified by the index -overwrites -.I ipi_spec_dst -for the routing table lookup. -.I ipi_addr -is ignored. -.IP -Not supported for -.B SOCK_STREAM -sockets. +.TQ +.BR IP_PKTINFO (2const) .TP .BR IP_RECVERR " (since Linux 2.2)" .\" Precisely: since Linux 2.1.15 @@ -513,7 +447,6 @@ See .BR ip (7). .SH NOTES .BR IP_RECVORIGDSTADDR , -.BR IP_PKTINFO , .BR IP_RECVERR , .BR IP_ROUTER_ALERT , and @@ -522,16 +455,6 @@ are Linux-specific. .\" IP_XFRM_POLICY is Linux-specific .\" IP_IPSEC_POLICY is a nonstandard extension, also present on some BSDs .P -Some other BSD sockets implementations provide -.B IP_RCVDSTADDR -and -.B IP_RECVIF -socket options to get the destination address and the interface of -received datagrams. -Linux has the more general -.B IP_PKTINFO -for the same task. -.P Some BSD sockets implementations also provide an .B IP_RECVTTL option, but an ancillary message with type diff --git a/man/man2const/IP_PKTINFO.2const b/man/man2const/IP_PKTINFO.2const new file mode 100644 index 000000000..e43270f74 --- /dev/null +++ b/man/man2const/IP_PKTINFO.2const @@ -0,0 +1,112 @@ +.\" Copyright, the authors of the Linux man-pages project +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.TH IP_PKTINFO 2const (date) "Linux man-pages (unreleased)" +.SH NAME +IP_PKTINFO +\- +information about the incoming packet +.SH LIBRARY +Standard C library +.RI ( libc ,\~ \-lc ) +.SH SYNOPSIS +.nf +.BR "#include " " /* Definition of " IP* " constants */" +.B #include +.P +.BI int\~setsockopt(int\~ sockfd ,\~IPPROTO_IP,\~IP_PKTINFO, +.BI " const\~int\~*" enable ,\~sizeof(int)); +.fi +.SH DESCRIPTION +.TP +.BR IP_PKTINFO " (since Linux 2.2)" +.\" Precisely: since Linux 2.1.68 +Pass an +.B IP_PKTINFO +ancillary message that contains a +.I pktinfo +structure that supplies some information about the incoming packet. +This works only for datagram oriented sockets. +The argument is a flag that tells the socket whether the +.B IP_PKTINFO +message should be passed or not. +The message itself can be sent/retrieved +only as a control message with a packet using +.BR recvmsg (2) +or +.BR sendmsg (2). +.IP +.in +4n +.EX +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 */ +}; +.EE +.in +.IP +When returned by +.BR recvmsg (2) , +.I ipi_ifindex +is the unique index of the interface the packet was received on. +.I ipi_spec_dst +is the preferred source address for replies to the given packet, +and +.I 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, +.I ipi_spec_dst +might belong to a different interface from the one that received the packet. +.IP +If +.B IP_PKTINFO +is passed to +.BR sendmsg (2) +and +.\" This field is grossly misnamed +.I 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 +.I ipi_ifindex +is not zero, +the primary local address of the interface specified by the index +overwrites +.I ipi_spec_dst +for the routing table lookup. +.I ipi_addr +is ignored. +.IP +Not supported for +.B SOCK_STREAM +sockets. +.SH ERRORS +See +.BR IPPROTO_IP (2const). +See +.BR setsockopt (2). +See +.BR ip (7). +.SH VERSIONS +Some other BSD sockets implementations provide +.B IP_RCVDSTADDR +and +.B IP_RECVIF +socket options to get the destination address and the interface of +received datagrams. +Linux has the more general +.B IP_PKTINFO +for the same task. +.SH STANDARDS +Linux. +.SH SEE ALSO +.BR IPPROTO_IP (2const), +.BR setsockopt (2), +.BR ip (7)