Commit | Line | Data |
---|---|---|
56e6bd55 KB |
1 | .\" Copyright (c) 1983 The Regents of the University of California. |
2 | .\" All rights reserved. | |
dc3d0ecb | 3 | .\" |
56e6bd55 KB |
4 | .\" Redistribution and use in source and binary forms are permitted |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
dc3d0ecb | 15 | .\" |
56e6bd55 KB |
16 | .\" @(#)getnetent.3 6.4 (Berkeley) %G% |
17 | .\" | |
18 | .TH GETNETENT 3 "" | |
dc3d0ecb KM |
19 | .UC 5 |
20 | .SH NAME | |
21 | getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent \- get network entry | |
22 | .SH SYNOPSIS | |
23 | .nf | |
24 | .ft B | |
25 | #include <netdb.h> | |
26 | .PP | |
27 | .ft B | |
28 | struct netent *getnetent() | |
29 | .PP | |
30 | .ft B | |
31 | struct netent *getnetbyname(name) | |
32 | char *name; | |
33 | .PP | |
34 | .ft B | |
f837eec2 | 35 | struct netent *getnetbyaddr(net, type) |
dc3d0ecb | 36 | long net; |
f837eec2 | 37 | int type; |
dc3d0ecb KM |
38 | .PP |
39 | .ft B | |
40 | setnetent(stayopen) | |
f837eec2 | 41 | int stayopen; |
dc3d0ecb KM |
42 | .PP |
43 | .ft B | |
44 | endnetent() | |
45 | .fi | |
46 | .SH DESCRIPTION | |
47 | .IR Getnetent , | |
48 | .IR getnetbyname , | |
49 | and | |
50 | .I getnetbyaddr | |
51 | each return a pointer to an object with the | |
52 | following structure | |
53 | containing the broken-out | |
54 | fields of a line in the network data base, | |
55 | .IR /etc/networks . | |
56 | .RS | |
57 | .PP | |
58 | .nf | |
59 | struct netent { | |
f837eec2 JL |
60 | char *n_name; /* official name of net */ |
61 | char **n_aliases; /* alias list */ | |
62 | int n_addrtype; /* net number type */ | |
63 | unsigned long n_net; /* net number */ | |
dc3d0ecb KM |
64 | }; |
65 | .ft R | |
66 | .ad | |
67 | .fi | |
68 | .RE | |
69 | .PP | |
70 | The members of this structure are: | |
71 | .TP \w'n_addrtype'u+2n | |
72 | n_name | |
73 | The official name of the network. | |
74 | .TP \w'n_addrtype'u+2n | |
75 | n_aliases | |
76 | A zero terminated list of alternate names for the network. | |
77 | .TP \w'n_addrtype'u+2n | |
78 | n_addrtype | |
79 | The type of the network number returned; currently only AF_INET. | |
80 | .TP \w'n_addrtype'u+2n | |
81 | n_net | |
82 | The network number. Network numbers are returned in machine byte | |
83 | order. | |
84 | .PP | |
85 | .I Getnetent | |
86 | reads the next line of the file, opening the file if necessary. | |
87 | .PP | |
88 | .I Setnetent | |
89 | opens and rewinds the file. If the | |
90 | .I stayopen | |
91 | flag is non-zero, | |
92 | the net data base will not be closed after each call to | |
ec178508 JL |
93 | .I getnetbyname |
94 | or | |
95 | .IR getnetbyaddr . | |
dc3d0ecb KM |
96 | .PP |
97 | .I Endnetent | |
98 | closes the file. | |
99 | .PP | |
100 | .I Getnetbyname | |
101 | and | |
102 | .I getnetbyaddr | |
103 | sequentially search from the beginning | |
104 | of the file until a matching | |
105 | net name or | |
f837eec2 | 106 | net address and type is found, |
dc3d0ecb KM |
107 | or until EOF is encountered. |
108 | Network numbers are supplied in host order. | |
109 | .SH FILES | |
110 | /etc/networks | |
111 | .SH "SEE ALSO" | |
112 | networks(5) | |
113 | .SH DIAGNOSTICS | |
114 | Null pointer | |
115 | (0) returned on EOF or error. | |
116 | .SH BUGS | |
117 | All information | |
118 | is contained in a static area | |
119 | so it must be copied if it is | |
120 | to be saved. Only Internet network | |
121 | numbers are currently understood. | |
122 | Expecting network numbers to fit | |
123 | in no more than 32 bits is probably | |
124 | naive. |