Date: Wed, 12 Jul 2000 16:14:54 +0100 (BST) From: Jan Grant <Jan.Grant@bristol.ac.uk> To: Alejandro Ramirez <ales@megared.net.mx> Cc: freebsd-questions <freebsd-questions@freebsd.org> Subject: Re: IP Address Convertion Formula??? Message-ID: <Pine.GHP.4.21.0007121611310.28327-100000@mail.ilrt.bris.ac.uk> In-Reply-To: <00b701bfec12$21ee6020$02c134c8@megared.net.mx>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 12 Jul 2000, Alejandro Ramirez wrote: > Hi All, > > I suppose that there is a formula to translate an address like > "1075040019" into 64.19.207.19, does anybody know something about it that > could explain to me???, or where can I see information about this. An IPv4 address is 4 bytes long. The long "representation" is just the numeric value of those 4 bytes. So: IP addr a.b.c.d Long value: a*16777216 + b*65536 + c*256 + d Long value: l a = floor(l / 16777216) b = floor((l - a * 16777216) / 65536) c = floor((l - a*16777216 - b*65536) / 256) d = (l - a*16777216 - b*65536 - c*256) Or in C: a = l >> 24; b = (l >> 16) & 0xff; c = (l >> 8) & 0xff; d = l & 0xff; -- jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ Tel +44(0)117 9287163 Fax +44 (0)117 9287112 RFC822 jan.grant@bris.ac.uk Semantic rules, OK? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GHP.4.21.0007121611310.28327-100000>