no retries or perror if EADDRNOTAVAIL, so can fail gracefully if no net
[unix-history] / usr / src / lib / libc / net / getnetent.3
CommitLineData
dc3d0ecb
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
60557779 5.\" @(#)getnetent.3 6.1 (Berkeley) %G%
dc3d0ecb 6.\"
60557779 7.TH GETNETENT 3N ""
dc3d0ecb
KM
8.UC 5
9.SH NAME
10getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent \- get network entry
11.SH SYNOPSIS
12.nf
13.ft B
14#include <netdb.h>
15.PP
16.ft B
17struct netent *getnetent()
18.PP
19.ft B
20struct netent *getnetbyname(name)
21char *name;
22.PP
23.ft B
24struct netent *getnetbyaddr(net)
25long net;
26.PP
27.ft B
28setnetent(stayopen)
29int stayopen
30.PP
31.ft B
32endnetent()
33.fi
34.SH DESCRIPTION
35.IR Getnetent ,
36.IR getnetbyname ,
37and
38.I getnetbyaddr
39each return a pointer to an object with the
40following structure
41containing the broken-out
42fields of a line in the network data base,
43.IR /etc/networks .
44.RS
45.PP
46.nf
47struct netent {
48 char *n_name; /* official name of net */
49 char **n_aliases; /* alias list */
50 int n_addrtype; /* net number type */
51 long n_net; /* net number */
52};
53.ft R
54.ad
55.fi
56.RE
57.PP
58The members of this structure are:
59.TP \w'n_addrtype'u+2n
60n_name
61The official name of the network.
62.TP \w'n_addrtype'u+2n
63n_aliases
64A zero terminated list of alternate names for the network.
65.TP \w'n_addrtype'u+2n
66n_addrtype
67The type of the network number returned; currently only AF_INET.
68.TP \w'n_addrtype'u+2n
69n_net
70The network number. Network numbers are returned in machine byte
71order.
72.PP
73.I Getnetent
74reads the next line of the file, opening the file if necessary.
75.PP
76.I Setnetent
77opens and rewinds the file. If the
78.I stayopen
79flag is non-zero,
80the net data base will not be closed after each call to
81.I getnetent
82(either directly, or indirectly through one of
83the other \*(lqgetnet\*(rq calls).
84.PP
85.I Endnetent
86closes the file.
87.PP
88.I Getnetbyname
89and
90.I getnetbyaddr
91sequentially search from the beginning
92of the file until a matching
93net name or
94net address is found,
95or until EOF is encountered.
96Network numbers are supplied in host order.
97.SH FILES
98/etc/networks
99.SH "SEE ALSO"
100networks(5)
101.SH DIAGNOSTICS
102Null pointer
103(0) returned on EOF or error.
104.SH BUGS
105All information
106is contained in a static area
107so it must be copied if it is
108to be saved. Only Internet network
109numbers are currently understood.
110Expecting network numbers to fit
111in no more than 32 bits is probably
112naive.