Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Aug 1995 09:47:56 +0200 (MET DST)
From:      J Wunsch <j@uriah.heep.sax.de>
To:        jkh@freefall.FreeBSD.org (Jordan K. Hubbard)
Cc:        freebsd-bugs@FreeBSD.org, joerg_wunsch@uriah.heep.sax.de
Subject:   Re: 950726-SNAP lp0/nfs install bug ?
Message-ID:  <199508120747.JAA18320@uriah.heep.sax.de>
In-Reply-To: <8860.808173419@freefall.FreeBSD.org> from "Jordan K. Hubbard" at Aug 11, 95 01:36:59 pm

next in thread | previous 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;


-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508120747.JAA18320>