From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 12 10:48:58 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DAB041065673 for ; Sat, 12 Feb 2011 10:48:58 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3fd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 4875F8FC16 for ; Sat, 12 Feb 2011 10:48:58 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [81.187.76.163]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.4/8.14.4) with ESMTP id p1CAmrTv090669 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 12 Feb 2011 10:48:54 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.8.3 smtp.infracaninophile.co.uk p1CAmrTv090669 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infracaninophile.co.uk; s=201001-infracaninophile; t=1297507734; bh=2XXnhw+rxSUooe3X3XQ2j3ppsk0KoA6efitYyD+sMzw=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Cc:Content-Type:Date:From:In-Reply-To: Message-ID:Mime-Version:References:To; z=Message-ID:=20<4D566585.7020802@infracaninophile.co.uk>|Date:=20S at,=2012=20Feb=202011=2010:48:37=20+0000|From:=20Matthew=20Seaman= 20|User-Agent:=20Mozilla/5.0=20(M acintosh=3B=20U=3B=20Intel=20Mac=20OS=20X=2010.6=3B=20en-US=3B=20r v:1.9.2.13)=20Gecko/20101207=20Thunderbird/3.1.7|MIME-Version:=201 .0|To:=20Devin=20Teske=20|CC:=20Ian=20Smith=20,=20freebsd-hackers@freebsd.org|Subject:=20Re: =20[RELEASE]=20host-setup(1):=20a=20dialog(1)-based=20utility=20fo r=20configuring=0D=0A=20FreeBSD|References:=20<20110211120031.9D37 510656E5@hub.freebsd.org>=09<20110212015155.I96449@sola.nimnet.asn .au>=20<1297447687.9144.6.camel@dt.vicor.com>|In-Reply-To:=20<1297 447687.9144.6.camel@dt.vicor.com>|X-Enigmail-Version:=201.1.1|Open PGP:=20id=3D60AE908C|Content-Type:=20multipart/signed=3B=20micalg= 3Dpgp-sha1=3B=0D=0A=20protocol=3D"application/pgp-signature"=3B=0D =0A=20boundary=3D"------------enig77090BAEC66020CB072AD5EF"; b=LwrsmrmtR0HFCXWjsREZzyIW7YPv3EtPVD3PLuF3YbGKE0xlhiOiAO+dmEXaN2jaK WRXq0SB9Gar9GKLjpWK5M4dRctOq6YpK67itPl02uTpW4Jw7NIcaMhq2dIrInYSbAH APitTYw2zJDnptPyNXwpYeBnAFLn0roGpLTvSVfQ= Message-ID: <4D566585.7020802@infracaninophile.co.uk> Date: Sat, 12 Feb 2011 10:48:37 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 To: Devin Teske References: <20110211120031.9D37510656E5@hub.freebsd.org> <20110212015155.I96449@sola.nimnet.asn.au> <1297447687.9144.6.camel@dt.vicor.com> In-Reply-To: <1297447687.9144.6.camel@dt.vicor.com> X-Enigmail-Version: 1.1.1 OpenPGP: id=60AE908C Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig77090BAEC66020CB072AD5EF" X-Virus-Scanned: clamav-milter 0.96.5 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_FAIL autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on lucid-nonsense.infracaninophile.co.uk Cc: freebsd-hackers@freebsd.org, Ian Smith Subject: Re: [RELEASE] host-setup(1): a dialog(1)-based utility for configuring FreeBSD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Feb 2011 10:48:58 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig77090BAEC66020CB072AD5EF Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 11/02/2011 18:08, Devin Teske wrote: > $ time blen2netmask 26 > 255.255.255.192 >=20 > real 0m0.004s > user 0m0.001s > sys 0m0.004s >=20 > That's pretty fast, I'd say ^_^ (faster than the other implementations > -- especially considering that it doesn't have to fork anything). There are only 33 possible netmasks -- did you evaluate simply enumerating them all and simply looking up the result? Hmmm... blen2netmask() { local nbits=3D$1 case $nbits in 0) echo '0.0.0.0' ;; 1) echo '128.0.0.0' ;; 2) echo '192.0.0.0' ;; 3) echo '224.0.0.0' ;; 4) echo '240.0.0.0' ;; 5) echo '248.0.0.0' ;; 6) echo '252.0.0.0' ;; 7) echo '254.0.0.0' ;; 8) echo '255.0.0.0' ;; 9) echo '255.128.0.0' ;; 10) echo '255.192.0.0' ;; 11) echo '255.224.0.0' ;; 12) echo '255.240.0.0' ;; 13) echo '255.248.0.0' ;; 14) echo '255.252.0.0' ;; 15) echo '255.254.0.0' ;; 16) echo '255.255.0.0' ;; 17) echo '255.255.128.0' ;; 18) echo '255.255.192.0' ;; 19) echo '255.255.224.0' ;; 20) echo '255.255.240.0' ;; 21) echo '255.255.248.0' ;; 22) echo '255.255.252.0' ;; 23) echo '255.255.254.0' ;; 24) echo '255.255.255.0' ;; 25) echo '255.255.255.128' ;; 26) echo '255.255.255.192' ;; 27) echo '255.255.255.224' ;; 28) echo '255.255.255.240' ;; 29) echo '255.255.255.248' ;; 30) echo '255.255.255.252' ;; 31) echo '255.255.255.254' ;; 32) echo '255.255.255.255' ;; *) echo "$nbits -- not a valid IPv4 netmask length" return -1 ;; esac return 0 } Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW --------------enig77090BAEC66020CB072AD5EF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1WZZUACgkQ8Mjk52CukIygCgCggPxCCvtv757bdavBR0dZy8fW xo8AnRV9d+ChTfQ90G4v6ycvSTtCRQRE =vvKn -----END PGP SIGNATURE----- --------------enig77090BAEC66020CB072AD5EF--