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