IP_PKTINFO2const
Information about the incoming packet
Usage
#include <netinet/in.h> /* Definition of IP* constants */ #include <sys/socket.h>
int setsockopt(int sockfd, IPPROTO_IP, IP_PKTINFO, const int *enable, sizeof(int));
Library
Standard C library (libc, -lc)
Overview
Pass an IP_PKTINFO ancillary message that contains a in_pktinfo(2type) 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 IP_PKTINFO message should be passed or not.
The message itself can be sent/retrieved only as a control message with a packet using recvmsg(2) or sendmsg(2).
Not supported for SOCK_STREAM sockets.
Errors
See IPPROTO_IP(2const). See setsockopt(2). See ip(7).
Versions
Some BSD sockets implementations provide IP_RCVDSTADDR and IP_RECVIF socket options to get the destination address and the interface of received datagrams. Linux has the more general IP_PKTINFO for the same task.