MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Networking Services Library Functions                ypclnt(3NSL)



NAME
     ypclnt, ypgetdefaultdomain, ypbind, ypunbind, ypmatch,
     ypfirst,     ypnext,    ypall,    yporder,    ypmaster,
     yperrstring, ypproterr - NIS Version 2 client interface

SYNOPSIS
     cc [ -flag... ] file... -lnsl [ library...]
     #include 
     #include 



     int ypbind(char *indomain);


     void ypunbind (char *indomain);


     int ypgetdefaultdomain(char **outdomain);


     int ypmatch(char *indomain, char *inmap, char *inkey, int inkeylen,
          char *char **outval, int *outvallen);


     int ypfirst(char *indomain, char *inmap, char **outkey, int *outkeylen,
          char **outval, int *outvallen);


     int ypnext(char *indomain, char *inmap, char *inkey, int *inkeylen,
          char **outkey, int *outkeylen, char **outval,
          int *outvallen);


     int ypall(char *indomain, char *inmap, struct ypallcallback *incallback);


     int yporder(char *indomain, char *inmap, unsigned long *outorder);


     int ypmaster(char *indomain, char *inmap, char **outname);


     char *yperrstring(int incode);


     int ypproterr(char *domain);


DESCRIPTION
     This package of functions provides an interface to NIS, Net-
     work  Information Service Version 2, formerly referred to as



SunOS 5.11          Last change: 23 Jan 2004                    1






Networking Services Library Functions                ypclnt(3NSL)



     YP. In this version of SunOS, NIS  version  2  is  supported
     only  for  compatibility  with previous versions. The recom-
     mended enterprise level information service is NIS]  or  NIS
     version  3. See NIS](1). The current SunOS supports only the
     client interface to NIS version  2.  This  client  interface
     will  in turn be served either by an existing ypserv process
     running on another machine on the network that has  an  ear-
     lier  version  of SunOS, or by a NIS] server running in "YP-
     compatibility mode". See rpc.nisd(1M). The NOTES section  in
     ypfiles(4) discusses the implications of being an NIS client
     of an NIS] server in  YP-compatibility  mode.  For  commands
     used  to  access  NIS from a client machine, see ypbind(1M),
     ypwhich(1), ypmatch(1), and ypcat(1).  The  package  can  be
     loaded from the standard library, /usr/lib/libnsl.so.1.


     All input parameter names begin with in.  Output  parameters
     begin  with out. Output parameters of type char ** should be
     addresses of uninitialized  character  pointers.  Memory  is
     allocated by the NIS client package using malloc(3C) and can
     be freed by the user code if it has no continuing  need  for
     it.  For  each  outkey and outval, two extra bytes of memory
     are allocated at the end  that  contain  NEWLINE  and  null,
     respectively,  but  these  two  bytes  are  not reflected in
     outkeylen or outvallen. The indomain and inmap strings  must
     be  non-null and null-terminated. String parameters that are
     accompanied by a count parameter may not be null,  but  they
     may point to null strings, with the count parameter indicat-
     ing this. Counted strings need not be null-terminated.


     All functions in this package of type int return 0  if  they
     succeed. Otherwise, they return a failure code (YPERxxxx).
     Failure codes are described in the ERORS section.

  Routines
     ypbind()                  To use the NIS name services, the
                                client process must be "bound" to
                                an NIS  server  that  serves  the
                                appropriate      domain     using
                                ypbind(). Binding  need  not  be
                                done  explicitly  by  user  code.
                                Binding  is  done   automatically
                                whenever  an  NIS lookup function
                                is called. The ypbind() function
                                can   be   called   directly  for
                                processes  that  make  use  of  a
                                backup  strategy , for example, a
                                local file in cases when NIS ser-
                                vices  are  not available. A pro-
                                cess should call ypunbind() when
                                it is finished using NIS in order



SunOS 5.11          Last change: 23 Jan 2004                    2






Networking Services Library Functions                ypclnt(3NSL)



                                to free up resources.


     ypunbind()                Each binding allocates or uses up
                                one    client    process   socket
                                descriptor.  Each  bound   domain
                                costs one socket descriptor. How-
                                ever, multiple  requests  to  the
                                same   domain   use   that   same
                                descriptor. The ypunbind() func-
                                tion  is  available at the client
                                interface  for   processes   that
                                explicitly  manage  their  socket
                                descriptors while accessing  mul-
                                tiple   domains.   The   call  to
                                ypunbind()  makes   the   domain
                                unbound,   and   frees  all  per-
                                process  and  per-node  resources
                                used to bind it.

                                If an RPC  failure  results  upon
                                use  of  a  binding,  that domain
                                will be unbound automatically. At
                                that  point,  the  ypclnt() layer
                                will retry a few  more  times  or
                                until   the  operation  succeeds,
                                provided  that  rpcbind(1M)   and
                                ypbind(1M)   are   running,   and
                                either:

                                    o    The client process  can-
                                         not  bind  a  server for
                                         the proper domain; or

                                    o    RPC  requests   to   the
                                         server fail.


                                Under    the    following    cir-
                                cumstances, the ypclnt layer will
                                return control to the user  code,
                                with  either  an error or success
                                code and the results:

                                    o    If an error is not  RPC-
                                         related.

                                    o    If rpcbind is  not  run-
                                         ning.

                                    o    If ypbind  is  not  run-
                                         ning.



SunOS 5.11          Last change: 23 Jan 2004                    3






Networking Services Library Functions                ypclnt(3NSL)



                                    o    If a bound  ypserv  pro-
                                         cess  returns any answer
                                         (success or failure).


     ypgetdefaultdomain()    NIS lookup calls  require  a  map
                                name   and   a  domain  name,  at
                                minimum.   The   client   process
                                should  know  the name of the map
                                of  interest.  Client   processes
                                fetch  the  node's default domain
                                by                        calling
                                ypgetdefaultdomain()  and  use
                                the  returned  outdomain  as  the
                                indomain  parameter to successive
                                NIS  name  service   calls.   The
                                domain  returned  is  the same as
                                that    returned    using     the
                                SISRPCDOMAIN   command  to  the
                                sysinfo(2) system call. The value
                                returned  in outdomain should not
                                be freed.


     ypmatch()                 The ypmatch()  function  returns
                                the   value   associated  with  a
                                passed  key.  This  key  must  be
                                exact because no pattern matching
                                is available. ypmatch() requires
                                a  full  YP  map  name,  such  as
                                hosts.byname,  instead   of   the
                                nickname hosts.


     ypfirst()                 The ypfirst()  function  returns
                                the first key-value pair from the
                                named map in the named domain.


     ypnext()                  The  ypnext()  function  returns
                                the  next  key-value  pair  in  a
                                named map.  The  inkey  parameter
                                must  be the outkey returned from
                                an initial call to ypfirst() (to
                                get the second key-value pair) or
                                the one  returned  from  the  nth
                                call to ypnext() (to get the nth
                                ] second key-value  pair).  Simi-
                                larly,   the  inkeylen  parameter
                                must be  the  outkeylen  returned
                                from  the  earlier  ypfirst() or
                                ypnext() call.



SunOS 5.11          Last change: 23 Jan 2004                    4






Networking Services Library Functions                ypclnt(3NSL)



                                The concept of first and next  is
                                particular  to  the  structure of
                                the  NIS  map  being   processed.
                                Retrieval order is not related to
                                either the lexical  order  within
                                any  original  (non-NIS name ser-
                                vice) data base, or to any  obvi-
                                ous  numerical  sorting  order on
                                the keys,  values,  or  key-value
                                pairs.  The only ordering guaran-
                                tee is  that  if  the  ypfirst()
                                function  is called on a particu-
                                lar map, and then  the  ypnext()
                                function  is repeatedly called on
                                the same map at the  same  server
                                until  the call fails with a rea-
                                son of YPERNOMORE, every  entry
                                in  the data base is seen exactly
                                once.  Further,   if   the   same
                                sequence  of  operations  is per-
                                formed on the  same  map  at  the
                                same server, the entries are seen
                                in the same order.

                                Under conditions of heavy  server
                                load   or   server  failure,  the
                                domain can become  unbound,  then
                                bound  once  again  (perhaps to a
                                different server) while a  client
                                is   running.  This  binding  can
                                cause  a  break  in  one  of  the
                                enumeration    rules.    Specific
                                entries may be seen twice by  the
                                client,   or  not  at  all.  This
                                approach protects the client from
                                error  messages that would other-
                                wise be returned in the midst  of
                                the  enumeration.  For  a  better
                                solution   to   enumerating   all
                                entries in a map, see ypall().


     ypall()                   The ypall() function provides  a
                                way  to  transfer  an  entire map
                                from server to client in a single
                                request  using  TCP  (rather than
                                UDP as with  other  functions  in
                                this  package).  The entire tran-
                                saction takes place as  a  single
                                RPC  request  and  response.  The
                                ypall()  function  can  be  used
                                just  like  any  other  NIS  name



SunOS 5.11          Last change: 23 Jan 2004                    5






Networking Services Library Functions                ypclnt(3NSL)



                                service procedure to identify the
                                map  in  the normal manner and to
                                supply the  name  of  a  function
                                that  will  be  called to process
                                each key-value  pair  within  the
                                map. The call to ypall() returns
                                only when the transaction is com-
                                pleted  (successfully  or  unsuc-
                                cessfully),  or   the   foreach()
                                function decides that it does not
                                want to see  any  more  key-value
                                pairs.

                                The third parameter  to  ypall()
                                is:

                                  struct ypallcallback *incallback {
                                       int (*foreach)();
                                       char *data;
                                  };

                                The function foreach() is called:

                                  foreach(int instatus, char *inkey,
                                  int inkeylen, char *inval,
                                  int invallen, char *indata);

                                The instatus parameter holds  one
                                of   the   return  status  values
                                defined  in   ,
                                either  YPTRUE or an error code.
                                See ypproterr(), for a  function
                                that converts an NIS name service
                                protocol error code to  a  ypclnt
                                layer error code.

                                The key and value parameters  are
                                somewhat  different  than defined
                                in the  synopsis  section  above.
                                First,  the  memory pointed to by
                                the inkey and inval parameters is
                                private to the ypall() function,
                                and  is  overwritten   with   the
                                arrival  of  each  new  key-value
                                pair. The foreach() function must
                                do something useful with the con-
                                tents of that memory, but it does
                                not  own  the  memory itself. Key
                                and value  objects  presented  to
                                the   foreach()   function   look
                                exactly  as  they   do   in   the
                                server's  map.  If  they were not



SunOS 5.11          Last change: 23 Jan 2004                    6






Networking Services Library Functions                ypclnt(3NSL)



                                NEWLINE-terminated    or    null-
                                terminated in the map, they would
                                not be here either.

                                The indata parameter is the  con-
                                tents   of  the  incallback->data
                                element passed to  ypall().  The
                                data   element  of  the  callback
                                structure can be  used  to  share
                                state   information  between  the
                                foreach() function and the  main-
                                line  code.  Its use is optional,
                                and no part  of  the  NIS  client
                                package  inspects  its  contents;
                                cast it to something  useful,  or
                                ignore it. The foreach() function
                                is Boolean. It should return 0 to
                                indicate  that  it  wants  to  be
                                called again for further received
                                key-value  pairs,  or non-zero to
                                stop the flow of key-value pairs.
                                If  foreach()  returns a non-zero
                                value, it is  not  called  again.
                                The  functional value of ypall()
                                is then 0.


     yporder()                 The yporder()  function  returns
                                the  order  number for a map. The
                                function is not supported if  the
                                ypbind  process  on  the client's
                                system is bound to an NIS] server
                                running    in   "YP-compatibility
                                mode".


     ypmaster()                The ypmaster() function  returns
                                the  machine  name  of the master
                                NIS server for a map.


     yperrstring()             The    yperrstring()    function
                                returns  a  pointer  to  an error
                                message  string  that  is   null-
                                terminated but contains no period
                                or NEWLINE.


     ypproterr()               The ypproterr()  function  takes
                                an   NIS  name  service  protocol
                                error code as input, and  returns
                                a   ypclnt()  layer  error  code,



SunOS 5.11          Last change: 23 Jan 2004                    7






Networking Services Library Functions                ypclnt(3NSL)



                                which can be used as an input  to
                                yperrstring().


RETURN VALUES
     All integer functions return 0 if the requested operation is
     successful,  or one of the following errors if the operation
     fails:

     YPERACES     Access violation.


     YPERBADARGS    The arguments to the function are bad.


     YPERBADB      The YP database is bad.


     YPERBUSY       The database is busy.


     YPERDOMAIN     Cannot bind to server on this domain.


     YPERKEY        No such key in map.


     YPERMAP        No such map in server's domain.


     YPERNODOM      Local domain name not set.


     YPERNOMORE     No more records in map database.


     YPERPMAP       Cannot communicate with rpcbind.


     YPERESRC      Resource allocation failure.


     YPERPC        RPC failure; domain has been unbound.


     YPERYPBIND     Cannot communicate with ypbind.


     YPERYPER      Internal YP server or client error.






SunOS 5.11          Last change: 23 Jan 2004                    8






Networking Services Library Functions                ypclnt(3NSL)



     YPERYPSERV     Cannot communicate with ypserv.


     YPERVERS       YP version mismatch.


FILES
     /usr/lib/libnsl.so.1

ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     MT-Level                     Safe                        
    


SEE ALSO
     NIS](1),  ypcat(1),  ypmatch(1),  ypwhich(1),  rpc.nisd(1M),
     rpcbind(1M), ypbind(1M), ypserv(1M), sysinfo(2), malloc(3C),
     ypfiles(4), attributes(5)





























SunOS 5.11          Last change: 23 Jan 2004                    9



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™