[Toybox] [PATCH] ping: print ttl

Rob Landley rob at landley.net
Mon Mar 2 16:12:00 PST 2020


On 2/28/20 9:45 AM, anatasluo wrote:
> Signed-off-by: anatasluo <luolongjuna at gmail.com>
> ---
>  lib/lib.h       |  2 ++
>  lib/net.c       | 22 ++++++++++++++++++++++
>  toys/net/ping.c | 40 +++++++++++++++++++++++++++++++++-------
>  3 files changed, 57 insertions(+), 7 deletions(-)

Sorry for the delay, I've been trying to see if there's a way to do this
_without_ using an iovec to read the data. (Which means I'm reading the kernel
code implementing it, among the half-dozen other things I'm currently juggling...)

But I did want to point out:

> -    xsetsockopt(TT.sock, SOL_SOCKET, SO_MARK, &len, 4);
> +    xsetsockopt(TT.sock, SOL_SOCKET, SO_MARK, &len, sizeof(len));
>    }

LP64 is a standard introduced during the 32->64 bit transition somewhere around
Y2 that says sizeof(char) = 1, sizeof(short) = 2, sizeof(int) = 3, and
sizeof(long) == sizeof(pointer), and sizeof(long long) is "at least" 64 bits (in
practice always exactly 8 bytes, but they should _specify_).

Linux, BSD, MacOSX, iOS, and Android all adhere to this standard. Windows does
_not_ (they went with LLP64 instead) for insane legacy reasons described... darn
it, the downside of discussing 20 year old things is all the pointers moved. I
should update the links on the design.html page, but here's Microsoft's insane
legacy reasons for going with LLP64 for the Win64 API:

  https://devblogs.microsoft.com/oldnewthing/20050131-00/?p=36563

Here, I just updated the design.html section to use archive.org for the unix.org
links:

  http://landley.net/toybox/design.html#bits

Rob


More information about the Toybox mailing list