1.\" Copyright (c) 1983, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93 33.\" $FreeBSD$ 34.\" 35.Dd June 4, 1993 36.Dt GETNETENT 3 37.Os BSD 4.2 38.Sh NAME 39.Nm getnetent , 40.Nm getnetbyaddr , 41.Nm getnetbyname , 42.Nm setnetent , 43.Nm endnetent 44.Nd get network entry 45.Sh SYNOPSIS 46.Fd #include <netdb.h> 47.Ft struct netent * 48.Fn getnetent void 49.Ft struct netent * 50.Fn getnetbyname "const char *name" 51.Ft struct netent * 52.Fn getnetbyaddr "unsigned long net" "int type" 53.Ft void 54.Fn setnetent "int stayopen" 55.Ft void 56.Fn endnetent void 57.Sh DESCRIPTION 58The 59.Fn getnetent , 60.Fn getnetbyname , 61and 62.Fn getnetbyaddr 63functions 64each return a pointer to an object with the 65following structure 66containing the broken-out 67fields of a line in the network data base, 68.Pa /etc/networks . 69.Bd -literal -offset indent 70struct netent { 71 char *n_name; /* official name of net */ 72 char **n_aliases; /* alias list */ 73 int n_addrtype; /* net number type */ 74 unsigned long n_net; /* net number */ 75}; 76.Ed 77.Pp 78The members of this structure are: 79.Bl -tag -width n_addrtype 80.It Fa n_name 81The official name of the network. 82.It Fa n_aliases 83A zero terminated list of alternate names for the network. 84.It Fa n_addrtype 85The type of the network number returned; currently only AF_INET. 86.It Fa n_net 87The network number. Network numbers are returned in machine byte 88order. 89.El 90.Pp 91The 92.Fn getnetent 93function 94reads the next line of the file, opening the file if necessary. 95.Pp 96The 97.Fn setnetent 98function 99opens and rewinds the file. If the 100.Fa stayopen 101flag is non-zero, 102the net data base will not be closed after each call to 103.Fn getnetbyname 104or 105.Fn getnetbyaddr . 106.Pp 107The 108.Fn endnetent 109function 110closes the file. 111.Pp 112The 113.Fn getnetbyname 114function 115and 116.Fn getnetbyaddr 117sequentially search from the beginning 118of the file until a matching 119net name or 120net address and type is found, 121or until 122.Dv EOF 123is encountered. The 124.Fa type 125must be 126.Dv AF_INET . 127Network numbers are supplied in host order. 128.Sh FILES 129.Bl -tag -width /etc/networks -compact 130.It Pa /etc/networks 131.El 132.Sh DIAGNOSTICS 133Null pointer 134(0) returned on 135.Dv EOF 136or error. 137.Sh SEE ALSO 138.Xr networks 5 139.Pp 140.%T RFC 1101 141.Sh HISTORY 142The 143.Fn getnetent , 144.Fn getnetbyaddr , 145.Fn getnetbyname , 146.Fn setnetent , 147and 148.Fn endnetent 149functions appeared in 150.Bx 4.2 . 151.Sh BUGS 152The data space used by 153these functions is static; if future use requires the data, it should be 154copied before any subsequent calls to these functions overwrite it. 155Only Internet network 156numbers are currently understood. 157Expecting network numbers to fit 158in no more than 32 bits is probably 159naive. 160