*BSD News Article 4543


Return to BSD News archive

Xref: sserve comp.unix.bsd:4591 comp.protocols.tcp-ip:19900
Newsgroups: comp.unix.bsd,comp.protocols.tcp-ip
Path: sserve!manuel!munnari.oz.au!network.ucsd.edu!sdd.hp.com!cs.utexas.edu!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: Re: getnetmaskent()?
Message-ID: <1992Sep5.005848.3022@fcom.cc.utah.edu>
Sender: news@fcom.cc.utah.edu
Organization: Weber State University  (Ogden, UT)
References: <BOB.92Sep4120430@volitans.MorningStar.Com>
Date: Sat, 5 Sep 92 00:58:48 GMT
Lines: 32

In article <BOB.92Sep4120430@volitans.MorningStar.Com> bob@MorningStar.Com (Bob Sutterfield) writes:
>BSD's getnetent() family of routines works with the contents of
>/etc/networks.  Is there a similar getnetmaskent() family for the
>information contained in /etc/netmasks?  I note that the Tahoe (or is
>it Reno?) <netdb.h> has no mention of a subnet mask, nor of a file
>where it might be found.
>
>Must I actually open() the file and parse it myself?  How barbaric! :-)

Actually, you need to look at the sources for ifconfig, which is capable
of printing out the netmask.  The netmask is an artifact of the paramters
to ifconfig initially, not an artifact of some attribute of your host
address.  This is especially true if you are subnetting some class of
subnet... for instance, 137.190.16.x as a subnet of the class B network
137.190.x.x.

One thing I generally do, but upon which you wouldn't be able to rely, is
to make a /etc/hosts entry for the netmask based on the network name.  Then
you can gethostent() it.


					Terry Lambert
					terry_lambert@gateway.novell.com
					terry@icarus.weber.edu
---
Any opinions in this posting are my own and not those of my present
or previous employers.
-- 
-------------------------------------------------------------------------------
                                                       terry@icarus.weber.edu
 "I have an 8 user poetic license" - me
-------------------------------------------------------------------------------