Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getnetent(3n) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought



GETNETENT(3n,L)             AIX Technical Reference             GETNETENT(3n,L)



-------------------------------------------------------------------------------
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent



PURPOSE

Gets network entry.

LIBRARY

Internet Library (libc.a)

SYNTAX

#include <netdb.h>


                struct netent *getnetent ( )void setnetent (stayopen)
                                            int stayopen;
                struct netent *getnetbyname (name)
                char *name;                 void endnetent ( )

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



DESCRIPTION

The getnetent, getnetbyname, and getnetbyaddr subroutines each return a pointer
to an object.  This object is a netent structure, which contains the field of a
line in the /etc/networks file (the network data base).  The netent structure
is defined in the netdb.h header file, and it contains the following members:

      char            *n_name;               /* official name of net */
      char            **n_aliases;           /* alias list           */
      int             n_addrtype;            /* net number type      */
      unsigned long   n_net;                 /* net number           */

The members of the structure are defined below:

n_name    Official name of the network.

n_aliases An array, terminated with a 0, of alternate names for the network.

n_addrtype
          The type of network number being returned.  AF_INET (defined in
          <sys/socket.h>) is the only valid value for this field.





Processed November 7, 1990      GETNETENT(3n,L)                               1





GETNETENT(3n,L)             AIX Technical Reference             GETNETENT(3n,L)



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

The getnetent subroutine reads the next line of the file.  If the file is not
open, getnetent opens it.

The setnetent subroutine opens and rewinds the file.  If the stayopen parameter
is 0, the net data base is closed after each call to getnetbyname or
getnetbyaddr.  Otherwise, the file is not closed after each call.

The endnetent subroutine closes the file.

The net parameter of getnetbyaddr subroutine contains the number of the network
to be located.  The type parameter specifies the address family for the
network.  The only supported value is AF_INET.

The getnetbyname and getnetbyaddr subroutines search the file sequentially from
its beginning until:

  o Finding a matching net name, for getnetbyname

  o Finding a matching net number and type for getnetbyaddr

  o Encountering the end of the file, for either routine.

Network numbers are supplied in host order.

RETURN VALUE

A pointer to a netent structure is returned on success.

Note:  The return value points to static data that is overwritten by subsequent
       calls.

A NULL pointer (0) is returned if an error occurs or the end of the file is
reached.

FILE

/etc/networks
            Network name data base.

RELATED INFORMATION

The discussion of /etc/networks in AIX TCP/IP User's Guide.










Processed November 7, 1990      GETNETENT(3n,L)                               2



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