1GETNETENT(3) Linux Programmer's Manual GETNETENT(3)
2
3
4
6 getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent - get net‐
7 work entry
8
10 #include <netdb.h>
11
12 struct netent *getnetent(void);
13
14 struct netent *getnetbyname(const char *name);
15
16 struct netent *getnetbyaddr(long net, int type);
17
18 void setnetent(int stayopen);
19
20 void endnetent(void);
21
23 The getnetent() function reads the next line from the file /etc/net‐
24 works and returns a structure netent containing the broken out fields
25 from the line. The /etc/networks file is opened if necessary.
26
27 The getnetbyname() function returns a netent structure for the line
28 from /etc/networks that matches the network name.
29
30 The getnetbyaddr() function returns a netent structure for the line
31 that matches the network number net of type type.
32
33 The setnetent() function opens and rewinds the /etc/networks file. If
34 stayopen is true (1), then the file will not be closed between calls to
35 getnetbyname() and getnetbyaddr().
36
37 The endnetent() function closes /etc/networks.
38
39 The netent structure is defined in <netdb.h> as follows:
40
41 struct netent {
42 char *n_name; /* official network name */
43 char **n_aliases; /* alias list */
44 int n_addrtype; /* net address type */
45 unsigned long int n_net; /* network number */
46 }
47
48 The members of the netent structure are:
49
50 n_name The official name of the network.
51
52 n_aliases
53 A zero terminated list of alternative names for the network.
54
55 n_addrtype
56 The type of the network number; always AF_INET.
57
58 n_net The network number in host byte order.
59
61 The getnetent(), getnetbyname() and getnetbyaddr() functions return the
62 netent structure, or a NULL pointer if an error occurs or the end of
63 the file is reached.
64
66 /etc/networks
67 networks database file
68
70 4.3BSD, POSIX.1-2001.
71
73 getprotoent(3), getservent(3), networks(5)
74 RFC 1101
75
76
77
78BSD 1993-05-15 GETNETENT(3)