Description |
![](../../img/s.gif) |
The
getnetent, getnetbyname, and getnetbyaddr
subroutines each return a pointer to an object with the following
structure. This structure contains fields found in the network protocol
database, /etc/networks.
struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net number type */
long n_net; /* net number */
};
|
The members of this structure are as follows:
- 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, always AF_INET.
- n_net
The network number. Network numbers are returned in
machine byte order.
The getnetent subroutine reads the next line of the file,
opening the file if necessary.
The setnetent subroutine opens and rewinds the file. If
the stayopen flag is non-zero, the network database is not
closed after each call to getnetent (either directly, or
indirectly through one of the other getnet calls).
The
endnetent subroutine closes the file.
The getnetbyname subroutine sequentially searches from
the beginning of the file until a network name (among either the official
names or the aliases) matching its parameter name is found,
or until EOF is encountered.
The getnetbyaddr subroutine sequentially searches from
the beginning of the file until a network number matching its parameter
net is found, or until EOF is encountered. The parameter net
must be in network order. The parameter type must be the constant
AF_INET.
Network numbers are supplied in host order. (Refer to the inet
section.)
Return Value |
![](../../img/s.gif) |
The getnetent, getnetbyname, and getnetbyaddr
subroutines return a null pointer (0) on EOF or when they are unable
to open NETWORKS.NET.SYS. The getnetbyaddr
subroutine also returns a null pointer if its parameter type
is invalid.