getnetbyaddr()

Get a network entry, given an address (Unix)

Synopsis:

#include <netdb.h>

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

Arguments:

net
The net address whose network entry you want to find.
type
The address type. This must currently be AF_INET.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

The getnetbyaddr() function gets an entry for the given address, net, from the network database, /etc/networks.

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 you pass a nonzero stayopen argument to setnetent(), the network database isn't 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.
/etc/nsswitch.conf
Name-service switch configuration file.

Classification:

POSIX 1003.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread No

Caveats:

This function uses static data; if you need the data for future use, copy it before any subsequent calls overwrite it.

Only Internet network numbers are currently understood.

See also:

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

/etc/networks, /etc/nsswitch.conf in the Utilities Reference