From owner-freebsd-questions@FreeBSD.ORG Mon Dec 4 17:21:43 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3A9D016A407 for ; Mon, 4 Dec 2006 17:21:43 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.187.76.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id C63C043CA5 for ; Mon, 4 Dec 2006 17:21:04 +0000 (GMT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from [IPv6:::1] (localhost [IPv6:::1]) by smtp.infracaninophile.co.uk (8.13.8/8.13.8) with ESMTP id kB4HLKwN068760 for ; Mon, 4 Dec 2006 17:21:20 GMT (envelope-from m.seaman@infracaninophile.co.uk) Authentication-Results: smtp.infracaninophile.co.uk from=m.seaman@infracaninophile.co.uk; sender-id=permerror; spf=permerror X-SenderID: Sendmail Sender-ID Filter v0.2.14 smtp.infracaninophile.co.uk kB4HLKwN068760 Message-ID: <4574590A.1010901@infracaninophile.co.uk> Date: Mon, 04 Dec 2006 17:21:14 +0000 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 1.5.0.8 (X11/20061110) MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <20061204124550.GA1766@host.my.domain> In-Reply-To: <20061204124550.GA1766@host.my.domain> X-Enigmail-Version: 0.94.0.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigAF6B2FEF42681479B939134D" X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (smtp.infracaninophile.co.uk [IPv6:::1]); Mon, 04 Dec 2006 17:21:30 +0000 (GMT) X-Virus-Scanned: ClamAV 0.88.6/2276/Mon Dec 4 08:15:27 2006 on happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00, DKIM_POLICY_TESTING,NO_RELAYS autolearn=ham version=3.1.7 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on happy-idiot-talk.infracaninophile.co.uk Subject: Re: Is there a standard function for converting IP address to number? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2006 17:21:43 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAF6B2FEF42681479B939134D Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable a@zeos.net wrote: > Is there a standard function converting four numbers to one 32-bit=20 > IP address? >=20 > I mean a function like >=20 > 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.=20 Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enigAF6B2FEF42681479B939134D Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----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----- --------------enigAF6B2FEF42681479B939134D--