NAME
getnetent
,
getnetbyaddr
, getnetbyname
,
setnetent
, endnetent
— get network entry
SYNOPSIS
#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);
DESCRIPTION
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:
- n_name
- The official name of the network.
- n_aliases
- A null-terminated list of alternate names for the network.
- n_addrtype
- The type of the network number returned; it is always
AF_INET
. - n_net
- The network number. Network numbers are returned in machine byte order.
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.
RETURN VALUES
The getnetbyaddr
() and
getnetbyname
() functions return
NULL
if the requested entry is not found.
The getnetent
() function always returns
NULL
.
FILES
- /etc/hosts
- The local host and network name database.
SEE ALSO
getaddrinfo(3), gethostbyname(3), getnameinfo(3), res_init(3), hosts(5)
STANDARDS
These functions conform to IEEE Std 1003.1-2008 (“POSIX.1”).
HISTORY
The getnetent
(),
getnetbyaddr
(),
getnetbyname
(), setnetent
(),
and endnetent
() functions appeared in
4.2BSD.
BUGS
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.