Is there a standard function for converting IP address to number?

Matthew Seaman m.seaman at infracaninophile.co.uk
Mon Dec 4 09:21:43 PST 2006


a at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20061204/b3d518f1/signature.pgp


More information about the freebsd-questions mailing list