GETNETENT(3) | Library Functions Manual | GETNETENT(3) |
getnetent
,
getnetbyaddr
, getnetbyname
,
setnetent
, endnetent
— get network entry
#include
<netdb.h>
struct netent *
getnetent
(void);
struct netent *
getnetbyname
(const
char *name);
struct netent *
getnetbyaddr
(in_addr_t
net, int type);
void
setnetent
(int
stayopen);
void
endnetent
(void);
The
getnetbyname
()
and
getnetbyaddr
()
functions return a pointer to an object with the following structure:
struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net number type */ in_addr_t n_net; /* net number */ };
The members of this structure are:
AF_INET
.On OpenBSD, these legacy functions perform a lookup in a similar fashion as gethostbyname(3) and gethostbyaddr(3), respectively. On other systems, they may use a separate network database file, /etc/networks.
In contrast to gethostbyaddr(3), the net argument is expected in machine byte order.
The
setnetent
(),
getnetent
(),
and
endnetent
()
functions are deprecated and no longer have any effect. They could be used
in the past to iterate over entries in the former file
/etc/networks.
The getnetbyaddr
() and
getnetbyname
() functions return
NULL
if the requested entry is not found.
The getnetent
() function always returns
NULL
.
getaddrinfo(3), gethostbyname(3), getnameinfo(3), res_init(3), hosts(5)
These functions conform to IEEE Std 1003.1-2008 (“POSIX.1”).
The getnetent
(),
getnetbyaddr
(),
getnetbyname
(), setnetent
(),
and endnetent
() functions appeared in
4.2BSD.
The data space used by these functions is static; if future use requires the data, it should be copied before any subsequent calls to these functions overwrite it. Only Internet network numbers are currently understood. Expecting network numbers to fit in no more than 32 bits is naive.
August 30, 2019 | OpenBSD-current |