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