The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Ralph Corderoy <ralph@inputplus.co.uk>
To: tuhs@minnie.tuhs.org
Subject: Re: [TUHS] conventions around zero padding in ip4
Date: Tue, 10 May 2022 11:49:03 +0100	[thread overview]
Message-ID: <20220510104903.DF66E221AE@orac.inputplus.co.uk> (raw)
In-Reply-To: <20220509140846.Qaxea%steffen@sdaoden.eu>

Hi Steffen,

> > It has been standardised; see inet_addr(3p) where ‘p’ means the
> > POSIX version of the man page or
> > https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_addr.html
> > 
> > Briefly, the string must be one of
> > 
> >     a.b.c.d
> >     a.b.cd
> >     a.bcd
> >     abcd
...
> "However", RFC 2553 says
>
>   RFC 2553       Basic Socket Interface Extensions for IPv6     March 1999
>
>      The address conversion functions -- inet_ntoa() and inet_addr() --
>      convert IPv4 addresses between binary and printable form.  These
>      functions are quite specific to 32-bit IPv4 addresses.  We have
>      designed two analogous functions that convert both IPv4 and IPv6
>      addresses

So that RFC added inet_pton(3) and inet_ntop(3).

> And for this POSIX says
>
>   If the af argument of inet_pton( ) is AF_INET, the src string
>   shall be in the standard IPv4 dotted-decimal form:
>   ddd.ddd.ddd.ddd where "ddd" is a one to three digit decimal
>   number between 0 and 255 (see inet_addr( )). The inet_pton()
>   function does not accept other formats [.]

True.  The non-POSIX inet_pton(3) here points out it only accepts IPv4
in decimal 3.1.4.1 form and pushes the programmer to getaddrinfo(3)
instead.

    NOTES

    Unlike inet_aton(3) and inet_addr(3), inet_pton() supports IPv6
    addresses.  On the other hand, inet_pton() accepts only IPv4 addresses
    in dotted-decimal notation, whereas inet_aton(3) and inet_addr(3)
    allow the more general numbers-and-dots notation (hexadecimal and
    octal number formats, and formats that don't require all four bytes
    to be explicitly written).  For an interface that handles both
    IPv6 addresses, and IPv4 addresses in numbers-and-dots notation,
    see getaddrinfo(3).

And POSIX's getaddrinfo(3p) punts to inet_addr(3p) for describing what
IPv4 formats are accepted, so we've gone full circle.

    If the specified address family is AF_INET or AF_UNSPEC, address
    strings using Internet standard dot notation as specified in
    inet_addr() are valid.

It looks to me that the RFC introduced a limited format which then had
to be standardised but the older interface is still being spread by
newer functions like getaddrinfo().

-- 
Cheers, Ralph.

  reply	other threads:[~2022-05-10 10:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07 16:14 ron minnich
2022-05-07 16:38 ` Bakul Shah
2022-05-07 16:48 ` Erik E. Fair
2022-05-07 18:49 ` Steffen Nurpmeso
2022-05-07 19:14 ` Warner Losh
2022-05-07 19:50   ` ron minnich
2022-05-07 19:57     ` ron minnich
2022-05-07 23:19   ` Bakul Shah
2022-05-07 23:49     ` Warner Losh
2022-05-08 10:28     ` Ralph Corderoy
2022-05-08  5:21 ` jason-tuhs
2022-05-08 10:22 ` Ralph Corderoy
2022-05-09 14:08   ` Steffen Nurpmeso
2022-05-10 10:49     ` Ralph Corderoy [this message]
2022-05-07 19:43 Noel Chiappa
2022-05-08 14:54 ` Michael Kjörling
2022-05-09 16:14 Noel Chiappa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220510104903.DF66E221AE@orac.inputplus.co.uk \
    --to=ralph@inputplus.co.uk \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).