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