Date: Sat, 12 Aug 1995 12:29:18 +0200 From: Mark Murray <mark@grondar.za> To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) Cc: jkh@freefall.FreeBSD.org (Jordan K. Hubbard), freebsd-bugs@FreeBSD.org Subject: Re: 950726-SNAP lp0/nfs install bug ? Message-ID: <199508121029.MAA28674@grumble.grondar.za>
next in thread | raw e-mail | index | archive | help
> As Jordan K. Hubbard wrote: > > > > Hmmm. Anyone willing to give me a little formula to calculate > > netmask based on IP address? Then I could also fill it in.. :-) > > unsigned char addr_high; > unsigned int netmask; > > addr_high = ...; /* highest byte of IP address */ > > if(addr_high < 128) > netmask = 0xff000000; > else if(addr_high < 192) > netmask = 0xffff0000; > else if(addr_high < 224) > netmask = 0xffffff00; > else > /* multicast or class E -- not particularly useful */ > netmask = 0xffffffff; You are not allowed to do this anymore. The ability to determine a netmask from the bit pattern of an IP address, while valid in the past is no longer so. Because of IP address space shortage, numbers are being assigned as address ranges, and the ABCDE class system is severely deprecated. When a sevice provider asks for a block of "class C's", they may get 19.20/16, which they can (If they only want "classic" class c's) distribute as 19.20.0/24 -> 19.20.255/24, even though 19.n.n.n is a class A by the old (and above) reckoning. In this case the above calculation will give a totally wrong netmask. M -- Mark Murray 46 Harvey Rd, Claremont, Cape Town 7700, South Africa +27 21 61-3768 GMT+0200 Finger mark@grumble.grondar.za for PGP key
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508121029.MAA28674>