getnetbyaddr()

get a network entry, given an address

Synopsis:

#include <netdb.h>

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

Description:

The getnetbyaddr() function gets an entry for the given address, net, from the network database, /etc/networks. The type argument specifies the address type, currently only AF_INET.

This function returns a pointer to a structure of type netent, which contains the broken-out fields of a line in the network database.

The setnetent() function opens and rewinds the file. If the stayopen flag is nonzero, the net database won't be closed after each call to getnetbyname() or getnetbyaddr().

The getnetbyname() and getnetbyaddr() functions sequentially search from the beginning of the file until a matching net name or net address and type is found, or until EOF is encountered. Network numbers are supplied in host order.

Returns:

A pointer to a valid netent structure, or NULL if an error occurs.

Files:

/etc/networks
Network name database file.

Classification:

POSIX 1003.1g (draft)

Safety:
Interrupt handler No
Signal handler No
Thread No

Caveats:

This function uses static data; if the data is needed for future use, it should be copied before any subsequent calls overwrite it.

Only Internet network numbers are currently understood.

See also:

endnetent(), getnetbyname(), getnetent(), netent, setnetent()

/etc/networks in the TCP/IP User's Guide