endnetent(), getnetbyaddr(), getnetbyname(), getnetent(), setnetent()

manipulate network database 

Function


SYNOPSIS

#include <netdb.h>

void endnetent();

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

struct netent *getnetbyname(const char *name);

struct netent *getnetent(void);

void setnetent(int stayopen);


DESCRIPTION

The getnetent(), getnetbyaddr(), and getnetbyname() functions each return a pointer to a netent structure, the members of which contain the fields of an entry in the network database, as follows:

n_name 

Official name of the network.

n_aliases 

A null-terminated array of alternate names.

n_addrtype 

The type of address being returned.

n_net 

The network number, in host byte order.

The getnetent() function reads the next entry of the database, opening a connection to the database if necessary.

The getnetbyaddr() function searches the database and finds an entry which matches the specified address family and which matches the specified address, opening a connection to the database if necessary.

The getnetbyname() function searches the database and finds an entry which matches the specified network name, opening a connection to the database if necessary.

The setnetent() function opens a connection to the network host database, and sets the position of the next entry to the first entry. If its parameter is non-zero, the connection to the database is not closed after each call to getnetent() (either directly, or indirectly through getnetbyaddr() or getnetbyname()).

The endnetent() function closes the connection to the database.


PARAMETERS

addr 

Points to the binary-format (that is, not null-terminated) address in host byte order.

type 

Is the type (address family) of the address.

name 

Is the network name for the network whose address is to be returned.

stayopen 

When non-zero, the connection to the database is not closed after each call to getnetbyaddr(), getnetbyname(), or getnetent().


RETURN VALUES

If successful, getnetbyaddr(), getnetbyname(), and getnetent() return a pointer to the netent structure described in the DESCRIPTION section. On failure, they return a null pointer.

The pointer that is returned points to a structure that is allocated by the NuTCRACKER Platform. The application must never attempt to modify this structure or to free any of its components. Furthermore, only one copy of this structure is allocated per thread; therefore, the application should copy any information it needs before issuing any other socket calls.


CONFORMANCE

UNIX 98, with exceptions


MULTITHREAD SAFETY LEVEL

endnetent(), getnetent(), setnetent(): Unsafe.

getnetbyaddr(), getnetbyname(): MT-Safe.


PORTING ISSUES

On 8.1/2012R2/10/2016/2019/11/2022, the networks file is in the drivers/etc directory under the 8.1/2012R2/10/2016/2019/11/2022 system directory. The _NutQueryWinNetFileDir() function returns the path where the network database files are located, regardless of platform.

The entries in the networks file on Windows may have extra 0 octets appended to them, to work around a problem with the Windows networking implementation. This issue is documented in article [Q131717] in the Microsoft Knowledge Base.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
_NutQueryWinNetFileDir(), endhostent(), endprotoent(), endservent(), gethostbyaddr(), gethostbyname(), gethostent(), getprotobyname(), getprotobynumber(), getprotoent(), getservbyname(), getservbyport(), getservent(), htonl(), inet_network(), inet_ntoa(), ntohl(), sethostent(), setprotoent(), setservent()


PTC MKS Toolkit 10.4 Documentation Build 39.