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       struct netent *getnetbyaddr(uint32_t net, int type);
16
17       void setnetent(int stayopen);
18       void endnetent(void);
19

DESCRIPTION

21       The getnetent() function reads the next entry from the  networks  data‐
22       base  and  returns  a netent structure containing the broken-out fields
23       from the entry.  A connection is opened to the database if necessary.
24
25       The getnetbyname() function returns a netent structure  for  the  entry
26       from the database that matches the network name.
27
28       The  getnetbyaddr()  function  returns a netent structure for the entry
29       from the database that matches the network number  net  of  type  type.
30       The net argument must be in host byte order.
31
32       The  setnetent()  function opens a connection to the database, and sets
33       the next entry to the first entry.  If stayopen is  nonzero,  then  the
34       connection  to  the database will not be closed between calls to one of
35       the getnet*() functions.
36
37       The endnetent() function closes the connection to the database.
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               uint32_t   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 NULL-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

RETURN VALUE

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

FILES

66       /etc/networks
67              networks database file
68

ATTRIBUTES

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

CONFORMING TO

91       POSIX.1-2001, POSIX.1-2008, 4.3BSD.
92

NOTES

94       In glibc versions before 2.2, the net argument of getnetbyaddr() was of
95       type long.
96

SEE ALSO

98       getnetent_r(3), getprotoent(3), getservent(3)
99       RFC 1101
100

COLOPHON

102       This page is part of release 5.12 of the Linux  man-pages  project.   A
103       description  of  the project, information about reporting bugs, and the
104       latest    version    of    this    page,    can     be     found     at
105       https://www.kernel.org/doc/man-pages/.
106
107
108
109GNU                               2021-03-22                      GETNETENT(3)
Impressum