Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getnetent(3N) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bcs_cat(1)

networks(4C)

getnetent(3N)  —  4 BSD

NAME

getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent − get network entry

SYNOPSIS

#include <netdb.h>

struct netent ∗getnetent()

struct netent ∗getnetbyname(name)
char ∗name;

struct netent ∗getnetbyaddr(net, type)
long net, type;

setnetent(stayopen)
int stayopen

endnetent()

DESCRIPTION

getnetent, getnetbyname, and getnetbyaddr each return a pointer to an object with the following structure containing the broken-out fields of a line in the network data base, /etc/networks. 

structnetent {
char∗n_name;/∗ official name of net ∗/
char∗∗n_aliases;/∗ alias list ∗/
intn_addrtype;/∗ net number type ∗/
longn_net;/∗ net number ∗/
};

The members of this structure are:

n_name The official name of the network. 

n_aliases A zero terminated list of alternate names for the network. 

n_addrtype The type of the network number returned; currently only AF_INET. 

n_net The network number.  Network numbers are returned in machine byte order. 

CX/UX supports both a proprietary version and an 88open Object Compatibility Standard Networking Supplement (OCSNS) version of getnetbyname and getnetbyaddr.  The OCSNS versions of these functions check for the existence of the function /etc/bcs_cat and if it exists and has proper execute permission, will issue a popen(3S) call of the command /etc/bcs_cat networks.  If the file does not exist, the functions will access the /etc/networks file. 

getnetent reads the next line of the /etc/networks file, opening the file if necessary and returning a pointer to a netent structure containing the file entry. 

Setnetent opens and rewinds the /etc/networks file.  If the stayopen flag is non-zero, the net data base will not be closed after each call to getnetent, getnetbyname, or getnetbyaddr. 

Endnetent closes the file /etc/networks and clears the stayopen flag. 

The functions getnetent, setnetent, and endnetent are defined in the 88open OCSNS.  Their functionality is the same as described above. 

Both versions of getnetbyname and getnetbyaddr sequentially search from the beginning of the file until a matching net name or net address is found, or until EOF is encountered.  Network numbers are supplied in host order.  The type parameter for getnetbyaddr must be AF_INET.  The 88open OCSNS versions of the above files may be accessed through special OCS options passed to cc(1) and/or ld(1). 

FILES

/etc/networks

SEE ALSO

bcs_cat(1), networks(4C)

DIAGNOSTICS

Null pointer (0) returned on EOF or error. 

BUGS

All information is contained in a static area so it must be copied if it is to be saved.  Only Internet network numbers are currently understood.  Expecting network numbers to fit in no more than 32 bits is probably naive. 

CX/UX Networking

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026