]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getnetent.3
ttyslot.3: tfix
[thirdparty/man-pages.git] / man3 / getnetent.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References consulted:
26.\" Linux libc source code
27.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28.\" 386BSD man pages
29.\" Modified Sat Jul 24 21:48:06 1993 by Rik Faith (faith@cs.unc.edu)
4b8c67d9 30.TH GETNETENT 3 2017-09-15 "GNU" "Linux Programmer's Manual"
fea681da
MK
31.SH NAME
32getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent \-
c13182ef 33get network entry
fea681da
MK
34.SH SYNOPSIS
35.nf
36.B #include <netdb.h>
68e4db0a 37.PP
fea681da 38.B struct netent *getnetent(void);
68e4db0a 39.PP
fea681da 40.BI "struct netent *getnetbyname(const char *" name );
68e4db0a 41.PP
15c15ebd 42.BI "struct netent *getnetbyaddr(uint32_t " net ", int " type );
68e4db0a 43.PP
fea681da 44.BI "void setnetent(int " stayopen );
68e4db0a 45.PP
fea681da
MK
46.B void endnetent(void);
47.fi
48.SH DESCRIPTION
60a90ecd
MK
49The
50.BR getnetent ()
8dea53c5 51function reads the next entry from the networks database
c6fa0841
MK
52and returns a
53.I netent
54structure containing
8dea53c5
MK
55the broken-out fields from the entry.
56A connection is opened to the database if necessary.
fea681da 57.PP
60a90ecd
MK
58The
59.BR getnetbyname ()
c6fa0841
MK
60function returns a
61.I netent
62structure
8dea53c5 63for the entry from the database
c6fa0841
MK
64that matches the network
65.IR name .
fea681da 66.PP
60a90ecd
MK
67The
68.BR getnetbyaddr ()
c6fa0841
MK
69function returns a
70.I netent
71structure
8dea53c5 72for the entry from the database
c6fa0841
MK
73that matches the network number
74.I net
75of type
76.IR type .
50fda6b3
MK
77The
78.I net
79argument must be in host byte order.
fea681da 80.PP
60a90ecd
MK
81The
82.BR setnetent ()
8dea53c5
MK
83function opens a connection to the database,
84and sets the next entry to the first entry.
c6fa0841
MK
85If
86.I stayopen
87is nonzero,
8dea53c5
MK
88then the connection to the database
89will not be closed between calls to one of the
90.BR getnet* ()
91functions.
fea681da 92.PP
60a90ecd
MK
93The
94.BR endnetent ()
8dea53c5 95function closes the connection to the database.
fea681da 96.PP
c6fa0841
MK
97The
98.I netent
99structure is defined in
100.I <netdb.h>
101as follows:
51f5698d 102.PP
a08ea57c 103.in +4n
b8302363 104.EX
fea681da 105struct netent {
e66cd0f2
MK
106 char *n_name; /* official network name */
107 char **n_aliases; /* alias list */
108 int n_addrtype; /* net address type */
109 uint32_t n_net; /* network number */
fea681da 110}
b8302363 111.EE
a08ea57c 112.in
fea681da 113.PP
c6fa0841
MK
114The members of the
115.I netent
116structure are:
fea681da
MK
117.TP
118.I n_name
119The official name of the network.
120.TP
121.I n_aliases
8dea53c5 122A NULL-terminated list of alternative names for the network.
fea681da
MK
123.TP
124.I n_addrtype
2f0af33b
MK
125The type of the network number; always
126.BR AF_INET .
fea681da
MK
127.TP
128.I n_net
129The network number in host byte order.
47297adb 130.SH RETURN VALUE
60a90ecd
MK
131The
132.BR getnetent (),
133.BR getnetbyname ()
134and
135.BR getnetbyaddr ()
d285b8b3 136functions return a pointer to a
c6fa0841
MK
137statically allocated
138.I netent
b437fdd9 139structure, or a null pointer if an
fea681da
MK
140error occurs or the end of the file is reached.
141.SH FILES
142.TP
143.I /etc/networks
144networks database file
d476c631
ZL
145.SH ATTRIBUTES
146For an explanation of the terms used in this section, see
147.BR attributes (7).
148.TS
149allbox;
150lbw14 lb lbw25
151l l l.
152Interface Attribute Value
153T{
154.BR getnetent ()
155T} Thread safety T{
156MT-Unsafe race:netent
157.br
158race:netentbuf env locale
159T}
160T{
161.BR getnetbyname ()
162T} Thread safety T{
163MT-Unsafe race:netbyname
164.br
165env locale
166T}
167T{
168.BR getnetbyaddr ()
169T} Thread safety T{
170MT-Unsafe race:netbyaddr
171.br
172locale
173T}
174T{
175.BR setnetent (),
176.br
177.BR endnetent ()
178T} Thread safety T{
179MT-Unsafe race:netent env
180.br
181locale
182T}
183.TE
847e0d88 184.sp 1
d476c631
ZL
185In the above table,
186.I netent
187in
188.I race:netent
189signifies that if any of the functions
bf7bc8b8
MK
190.BR setnetent (),
191.BR getnetent (),
d476c631 192or
bf7bc8b8 193.BR endnetent ()
d476c631
ZL
194are used in parallel in different threads of a program,
195then data races could occur.
47297adb 196.SH CONFORMING TO
dfac2a0a 197POSIX.1-2001, POSIX.1-2008, 4.3BSD.
15c15ebd
MK
198.SH NOTES
199In glibc versions before 2.2, the
200.I net
201argument of
202.BR getnetbyaddr ()
203was of type
204.IR long .
47297adb 205.SH SEE ALSO
d285b8b3 206.BR getnetent_r (3),
fea681da 207.BR getprotoent (3),
8dea53c5
MK
208.BR getservent (3)
209.\" .BR networks (5)
fea681da 210.br
331da7c3 211RFC\ 1101