From owner-freebsd-questions Wed Jul 12 8:15:32 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dire.bris.ac.uk (dire.bris.ac.uk [137.222.10.60]) by hub.freebsd.org (Postfix) with ESMTP id 6E35A37BCA9 for ; Wed, 12 Jul 2000 08:15:27 -0700 (PDT) (envelope-from Jan.Grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk by dire.bris.ac.uk with SMTP-PRIV with ESMTP; Wed, 12 Jul 2000 16:14:55 +0100 Received: from localhost (cmjg@localhost) by mail.ilrt.bris.ac.uk (8.8.7/8.8.8) with ESMTP id QAA14114; Wed, 12 Jul 2000 16:14:54 +0100 (BST) Date: Wed, 12 Jul 2000 16:14:54 +0100 (BST) From: Jan Grant To: Alejandro Ramirez Cc: freebsd-questions Subject: Re: IP Address Convertion Formula??? In-Reply-To: <00b701bfec12$21ee6020$02c134c8@megared.net.mx> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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