A mirror of Man pages
Go to file
bert hubert 2ca483cd4b ip.7: IP_RECVTTL error fixed
I need to get the TTL of UDP datagrams from userspace, so I set
the IP_RECVTTL socket option.  And as promised by ip.7, I then get
IP_TTL messages from recvfrom.  However, unlike what the manpage
promises, the TTL field gets passed as a 32 bit integer.

The following userspace code works:

  uint32_t ttl32;
  for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(msgh,cmsg)) {
    if ((cmsg->cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_TTL) &&
        CMSG_LEN(sizeof(ttl32)) == cmsg->cmsg_len) {

      memcpy(&ttl32, CMSG_DATA(cmsg), sizeof(ttl32));
      *ttl=ttl32;
      return true;
    }
    else
      cerr<<"Saw something else "<<(cmsg->cmsg_type == IP_TTL) <<
		", "<<(int)cmsg->cmsg_level<<", "<<cmsg->cmsg_len<<", "<<
		CMSG_LEN(1)<<endl;
  }

The 'else' field was used to figure out I go the length wrong.

Note from mtk:

Reading the source code also seems to confirm this, from
net/ipv4/ip_sockglue.c:

[[
static void ip_cmsg_recv_ttl(struct msghdr *msg, struct sk_buff *skb)
{
        int ttl = ip_hdr(skb)->ttl;
        put_cmsg(msg, SOL_IP, IP_TTL, sizeof(int), &ttl);
}
]]

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-25 10:49:09 +01:00
man1 time.1: Update bug reporting address 2019-01-17 08:36:08 +13:00
man2 capget.2: Remove first paragraph, which repeats details from capabilities(7) 2019-02-25 10:48:57 +01:00
man3 bstring.3: Correct argument list for memmem() prototype 2019-01-10 13:38:42 +13:00
man4 clone.2, prctl.2, st.4, proc.5: Change references to '2.6.0-test*' series kernels to just '2.6.0' 2018-11-19 13:09:55 +01:00
man5 proc.5: SEE ALSO: add htop(1) and pstree(1) 2019-02-01 01:37:03 +01:00
man6 intro.6: wfix 2017-08-25 21:41:03 +02:00
man7 ip.7: IP_RECVTTL error fixed 2019-02-25 10:49:09 +01:00
man8 zic.8: Sync from tzdb upstream 2018-11-01 15:09:33 +01:00
scripts scripts: mark them executable 2018-05-31 21:34:32 +02:00
Changes Start of man-pages-4.17: updating Changes and Changes.old 2018-04-30 21:34:48 +02:00
Changes.old Changes.old: tfix 2019-01-10 13:38:42 +13:00
Makefile Makefile: Remove a redundant comment 2017-11-20 10:38:10 +01:00
README README: tfix 2017-05-13 20:14:15 +02:00
man-pages-4.17.Announce Start of man-pages-4.17: updating .Announce and .lsm files 2018-04-30 21:34:48 +02:00
man-pages-4.17.lsm Start of man-pages-4.17: updating .Announce and .lsm files 2018-04-30 21:34:48 +02:00

README

This package contains Linux man pages for sections 1 through 8.  Some
more information is given in the 'man-pages-x.y.Announce' file.

Installing and uninstalling
===========================
"make install" will copy these man pages to /usr/share/man/man[1-8].

To install to a path different from /usr, use
"make install prefix=/install/path".

"make remove" or "make uninstall" will remove any man page in this
distribution from its destination.  Use with caution, and remember to
use "prefix" if desired, as with the "install" target.

"make" or "make all" will perform "make uninstall" followed by "make
install".

Man page overlap and duplication
================================
Note that sometimes these pages are duplicates of pages also distributed
in other packages.  This has been reported about:

man page                also found in
-------------------------------------
resolver.3              bind-utils, bind9utils
resolv.conf.5           "
passwd.5                shadow, passwd
mailaddr.7              ?

Copyrights
==========
See the 'man-pages-x.y.Announce' file.

Homepage
========
For much more about the Linux man-pages project, see
http://www.kernel.org/doc/man-pages/index.html.