1GETNETENT(3)               Linux Programmer's Manual              GETNETENT(3)
2
3
4

NAME

6       getnetent,  getnetbyname, getnetbyaddr, setnetent, endnetent - get net‐
7       work entry
8

SYNOPSIS

10       #include <netdb.h>
11
12       struct netent *getnetent(void);
13
14       struct netent *getnetbyname(const char *name);
15
16       struct netent *getnetbyaddr(uint32_t net, int type);
17
18       void setnetent(int stayopen);
19
20       void endnetent(void);
21

DESCRIPTION

23       The getnetent() function reads the next entry from the  networks  data‐
24       base  and  returns  a netent structure containing the broken-out fields
25       from the entry.  A connection is opened to the database if necessary.
26
27       The getnetbyname() function returns a netent structure  for  the  entry
28       from the database that matches the network name.
29
30       The  getnetbyaddr()  function  returns a netent structure for the entry
31       from the database that matches the network number  net  of  type  type.
32       The net argument must be in host byte order.
33
34       The  setnetent()  function opens a connection to the database, and sets
35       the next entry to the first entry.  If stayopen is  nonzero,  then  the
36       connection  to  the database will not be closed between calls to one of
37       the getnet*() functions.
38
39       The endnetent() function closes the connection to the database.
40
41       The netent structure is defined in <netdb.h> as follows:
42
43           struct netent {
44               char      *n_name;     /* official network name */
45               char     **n_aliases;  /* alias list */
46               int        n_addrtype; /* net address type */
47               uint32_t   n_net;      /* network number */
48           }
49
50       The members of the netent structure are:
51
52       n_name The official name of the network.
53
54       n_aliases
55              A NULL-terminated list of alternative names for the network.
56
57       n_addrtype
58              The type of the network number; always AF_INET.
59
60       n_net  The network number in host byte order.
61

RETURN VALUE

63       The getnetent(), getnetbyname() and getnetbyaddr() functions  return  a
64       pointer  to  a statically allocated netent structure, or a null pointer
65       if an error occurs or the end of the file is reached.
66

FILES

68       /etc/networks
69              networks database file
70

ATTRIBUTES

72       For  an  explanation  of  the  terms  used   in   this   section,   see
73       attributes(7).
74
75       ┌───────────────┬───────────────┬───────────────────────────┐
76Interface      Attribute     Value                     
77       ├───────────────┼───────────────┼───────────────────────────┤
78getnetent()    │ Thread safety │ MT-Unsafe race:netent     │
79       │               │               │ race:netentbuf env locale │
80       ├───────────────┼───────────────┼───────────────────────────┤
81getnetbyname() │ Thread safety │ MT-Unsafe race:netbyname  │
82       │               │               │ env locale                │
83       ├───────────────┼───────────────┼───────────────────────────┤
84getnetbyaddr() │ Thread safety │ MT-Unsafe race:netbyaddr  │
85       │               │               │ locale                    │
86       ├───────────────┼───────────────┼───────────────────────────┤
87setnetent(),   │ Thread safety │ MT-Unsafe race:netent env │
88endnetent()    │               │ locale                    │
89       └───────────────┴───────────────┴───────────────────────────┘
90       In  the above table, netent in race:netent signifies that if any of the
91       functions setnetent(), getnetent(), or endnetent() are used in parallel
92       in different threads of a program, then data races could occur.
93

CONFORMING TO

95       POSIX.1-2001, POSIX.1-2008, 4.3BSD.
96

NOTES

98       In glibc versions before 2.2, the net argument of getnetbyaddr() was of
99       type long.
100

SEE ALSO

102       getnetent_r(3), getprotoent(3), getservent(3)
103       RFC 1101
104

COLOPHON

106       This page is part of release 5.02 of the Linux  man-pages  project.   A
107       description  of  the project, information about reporting bugs, and the
108       latest    version    of    this    page,    can     be     found     at
109       https://www.kernel.org/doc/man-pages/.
110
111
112
113GNU                               2017-09-15                      GETNETENT(3)
Impressum