OpenBSD manual page server

Manual Page Search Parameters

GETNETENT(3) Library Functions Manual GETNETENT(3)

getnetent, getnetbyaddr, getnetbyname, setnetent, endnetentget network entry

#include <netdb.h>

struct netent *

struct netent *
getnetbyname(const char *name);

struct netent *
getnetbyaddr(in_addr_t net, int type);

setnetent(int stayopen);


The () and () 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:

The official name of the network.
A null-terminated list of alternate names for the network.
The type of the network number returned; it is always AF_INET.
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 (), (), and () 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.

The local host and network name database.

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-6.7