INtime SDK Help
getnetent (legacy networking)
INtime Help

The getnetbyaddr( ), getnetbyname( ), setnetent( ), getnetent( ), and endnetent( ) functions return information about a network entry from the NETWORKSFILE database.

You can access this database file via the INtime Configuration utility:

  1. Start>Programs>INtime>INtime Configuration
  2. Select your node in Node Management.
  3. Click the Advanced tab.
  4. Ensure you are in the CLIB section. The database file displays in the listbox.

Syntax

#include <netdb.h>

struct netent *getnetbyname(name)  
    char *name;  

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

void setnetent(stayopen) int stayopen;  
    struct netent *getnetent( ) 

void endnetent( )

Remarks

A specific entry can be retrieved by the network name with getnetbyname( ), or by its Internet address with getnetbyaddr( ). Both functions sequentially search the database for the specified entry. The network address used in the getnetbyaddr( ) call should be in host order; the network type should be AF_INET, as defined in the system include file <sys/socket.h>.

All returned information is contained in a static area so, to save, it must be copied. Only Internet network numbers are understood.

To retrieve a sequential series of network entries, it is more efficient to use the setnetent( ), getnetent( ), and endnetent( ) functions. You must pair the calls to setnetent( ) and endnetent( ).

The setnetent( ) function opens or rewinds (sets the file pointer to 0) the networks database.

If passed a 0 value for the argument stayopen, setnetent( ) opens the :config:networks file. Subsequent calls to the getnetent( ) function return the next entry in the networks database until end of file, opening it if necessary. The endnetent( ) function closes the database.

If passed a non-zero value for the argument stayopen, setnetent( ) rewinds the :config:networks file or opens it, if it is not already open. Subsequent calls to the getnetent( ) function return the next entry in the networks database until end of file, opening it if necessary. The networks database remains open until the application executes exit( ). Calling endnetent( ) does not close the database.

The network entry has this structure:

struct netent {
    char * n_name;
    char ** n_aliases;
    int  n_addrtype;
    unsigned long n_net; 
};

Where:

n_name
The official name of the network.
n_aliases
A list of alternate names for the network. The list is terminated by a null string.
n_addrtype
The type of network address; AF_INET is the only type supported.
n_net
The network number in host order.

Return Values

A null pointer is returned by getnetbyaddr( ), getnetbyname( ), and getnetent( ) on an EOF or on an error.

Requirements

Versions Defined in Include Link to
INtime 3.1 intime/rt/include/netdb.h net.db.h netiff3m.lib
See Also