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