]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/getnetent.3
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man3 / getnetent.3
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" 386BSD man pages
10 .\" Modified Sat Jul 24 21:48:06 1993 by Rik Faith (faith@cs.unc.edu)
11 .TH getnetent 3 (date) "Linux man-pages (unreleased)"
12 .SH NAME
13 getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent \-
14 get network entry
15 .SH LIBRARY
16 Standard C library
17 .RI ( libc ", " \-lc )
18 .SH SYNOPSIS
19 .nf
20 .B #include <netdb.h>
21 .P
22 .B struct netent *getnetent(void);
23 .P
24 .BI "struct netent *getnetbyname(const char *" name );
25 .BI "struct netent *getnetbyaddr(uint32_t " net ", int " type );
26 .P
27 .BI "void setnetent(int " stayopen );
28 .B void endnetent(void);
29 .fi
30 .SH DESCRIPTION
31 The
32 .BR getnetent ()
33 function reads the next entry from the networks database
34 and returns a
35 .I netent
36 structure containing
37 the broken-out fields from the entry.
38 A connection is opened to the database if necessary.
39 .P
40 The
41 .BR getnetbyname ()
42 function returns a
43 .I netent
44 structure
45 for the entry from the database
46 that matches the network
47 .IR name .
48 .P
49 The
50 .BR getnetbyaddr ()
51 function returns a
52 .I netent
53 structure
54 for the entry from the database
55 that matches the network number
56 .I net
57 of type
58 .IR type .
59 The
60 .I net
61 argument must be in host byte order.
62 .P
63 The
64 .BR setnetent ()
65 function opens a connection to the database,
66 and sets the next entry to the first entry.
67 If
68 .I stayopen
69 is nonzero,
70 then the connection to the database
71 will not be closed between calls to one of the
72 .BR getnet* ()
73 functions.
74 .P
75 The
76 .BR endnetent ()
77 function closes the connection to the database.
78 .P
79 The
80 .I netent
81 structure is defined in
82 .I <netdb.h>
83 as follows:
84 .P
85 .in +4n
86 .EX
87 struct netent {
88 char *n_name; /* official network name */
89 char **n_aliases; /* alias list */
90 int n_addrtype; /* net address type */
91 uint32_t n_net; /* network number */
92 }
93 .EE
94 .in
95 .P
96 The members of the
97 .I netent
98 structure are:
99 .TP
100 .I n_name
101 The official name of the network.
102 .TP
103 .I n_aliases
104 A NULL-terminated list of alternative names for the network.
105 .TP
106 .I n_addrtype
107 The type of the network number; always
108 .BR AF_INET .
109 .TP
110 .I n_net
111 The network number in host byte order.
112 .SH RETURN VALUE
113 The
114 .BR getnetent (),
115 .BR getnetbyname (),
116 and
117 .BR getnetbyaddr ()
118 functions return a pointer to a
119 statically allocated
120 .I netent
121 structure, or a null pointer if an
122 error occurs or the end of the file is reached.
123 .SH FILES
124 .TP
125 .I /etc/networks
126 networks database file
127 .SH ATTRIBUTES
128 For an explanation of the terms used in this section, see
129 .BR attributes (7).
130 .TS
131 allbox;
132 lb lb lbx
133 l l l.
134 Interface Attribute Value
135 T{
136 .na
137 .nh
138 .BR getnetent ()
139 T} Thread safety T{
140 .na
141 .nh
142 MT-Unsafe race:netent
143 race:netentbuf env locale
144 T}
145 T{
146 .na
147 .nh
148 .BR getnetbyname ()
149 T} Thread safety T{
150 .na
151 .nh
152 MT-Unsafe race:netbyname
153 env locale
154 T}
155 T{
156 .na
157 .nh
158 .BR getnetbyaddr ()
159 T} Thread safety T{
160 .na
161 .nh
162 MT-Unsafe race:netbyaddr
163 locale
164 T}
165 T{
166 .na
167 .nh
168 .BR setnetent (),
169 .BR endnetent ()
170 T} Thread safety T{
171 .na
172 .nh
173 MT-Unsafe race:netent env
174 locale
175 T}
176 .TE
177 .P
178 In the above table,
179 .I netent
180 in
181 .I race:netent
182 signifies that if any of the functions
183 .BR setnetent (),
184 .BR getnetent (),
185 or
186 .BR endnetent ()
187 are used in parallel in different threads of a program,
188 then data races could occur.
189 .SH STANDARDS
190 POSIX.1-2008.
191 .SH HISTORY
192 POSIX.1-2001, 4.3BSD.
193 .P
194 Before glibc 2.2, the
195 .I net
196 argument of
197 .BR getnetbyaddr ()
198 was of type
199 .IR long .
200 .SH SEE ALSO
201 .BR getnetent_r (3),
202 .BR getprotoent (3),
203 .BR getservent (3)
204 .\" .BR networks (5)
205 .br
206 RFC\ 1101