Back to index

glibc  2.9
nis_ping.c
Go to the documentation of this file.
00001 /* Copyright (c) 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <rpcsvc/nis.h>
00021 
00022 #include "nis_xdr.h"
00023 #include "nis_intern.h"
00024 
00025 void
00026 nis_ping (const_nis_name dirname, unsigned int utime,
00027          const nis_object *dirobj)
00028 {
00029   nis_result *res = NULL;
00030   nis_object *obj;
00031   ping_args args;
00032   unsigned int i;
00033 
00034   if (dirname == NULL && dirobj == NULL)
00035     abort ();
00036 
00037   if (dirobj == NULL)
00038     {
00039       res = nis_lookup (dirname, MASTER_ONLY);
00040       if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS)
00041        {
00042          nis_freeresult (res);
00043          return;
00044        }
00045       obj = res->objects.objects_val;
00046     }
00047   else
00048     obj = (nis_object *) dirobj;
00049 
00050   /* Check if obj is really a diryectory object */
00051   if (__type_of (obj) != NIS_DIRECTORY_OBJ)
00052     {
00053       nis_freeresult (res);
00054       return;
00055     }
00056 
00057   if (dirname == NULL)
00058     args.dir = obj->DI_data.do_name;
00059   else
00060     args.dir = (char *) dirname;
00061   args.stamp = utime;
00062 
00063   /* Send the ping only to replicas */
00064   for (i = 1; i < obj->DI_data.do_servers.do_servers_len; ++i)
00065     __do_niscall2 (&obj->DI_data.do_servers.do_servers_val[i], 1,
00066                  NIS_PING, (xdrproc_t) _xdr_ping_args,
00067                  (caddr_t) &args, (xdrproc_t) xdr_void,
00068                  (caddr_t) NULL, 0, NULL);
00069   nis_freeresult (res);
00070 }