Date: Mon, 04 Dec 2006 17:21:14 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: freebsd-questions@freebsd.org Subject: Re: Is there a standard function for converting IP address to number? Message-ID: <4574590A.1010901@infracaninophile.co.uk> In-Reply-To: <20061204124550.GA1766@host.my.domain> References: <20061204124550.GA1766@host.my.domain>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
a@zeos.net wrote:
> Is there a standard function converting four numbers to one 32-bit
> IP address?
>
> I mean a function like
>
> f(i, j, k, l) {
> return (((((i << 8) | j) << 8) | k) << 8) | l;
> }
Not exactly. inet_ntoa() and inet_aton() are about the closest I can
think of. There's a range of similar functions described in the
inet(3) man page for converting from struct in_addr (essentially
an IPv4 address expressed as a 32bit int) to a textual representation
of an IPv4 number, and vice versa.
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFdFkP8Mjk52CukIwRCAOjAJ9pwLTgSdjhcPf0aSBHFOPFLqxfhQCfSpiH
LsCJIcIbLDhScIl+Mp5wpEQ=
=eJjJ
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4574590A.1010901>
