Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getnetent(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent

Purpose

     Gets network entry.

Library

     Sockets Library (libsock.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      */
          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  is the  only valid  value for  this
                  field.

     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 getnetent.  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, or

     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 Interface Program for
     use with TCP/IP.

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