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