]> git.ipfire.org Git - thirdparty/glibc.git/blame - nis/nis_ping.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nis / nis_ping.c
CommitLineData
bfff8b1b 1/* Copyright (c) 1997-2017 Free Software Foundation, Inc.
51702635 2 This file is part of the GNU C Library.
32abdb71 3 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
51702635
UD
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
51702635
UD
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13 Lesser General Public License for more details.
51702635 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
51702635
UD
18
19#include <rpcsvc/nis.h>
91eee4dd
UD
20
21#include "nis_xdr.h"
51702635
UD
22#include "nis_intern.h"
23
24void
a1129917
UD
25nis_ping (const_nis_name dirname, unsigned int utime,
26 const nis_object *dirobj)
51702635
UD
27{
28 nis_result *res = NULL;
29 nis_object *obj;
30 ping_args args;
a1129917 31 unsigned int i;
51702635
UD
32
33 if (dirname == NULL && dirobj == NULL)
34 abort ();
35
36 if (dirobj == NULL)
37 {
3996f34b 38 res = nis_lookup (dirname, MASTER_ONLY);
32abdb71
UD
39 if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS)
40 {
7960f2a7 41 nis_freeresult (res);
32abdb71
UD
42 return;
43 }
51702635
UD
44 obj = res->objects.objects_val;
45 }
46 else
714a562f 47 obj = (nis_object *) dirobj;
51702635
UD
48
49 /* Check if obj is really a diryectory object */
dfd2257a 50 if (__type_of (obj) != NIS_DIRECTORY_OBJ)
3996f34b 51 {
7960f2a7 52 nis_freeresult (res);
3996f34b
UD
53 return;
54 }
51702635
UD
55
56 if (dirname == NULL)
57 args.dir = obj->DI_data.do_name;
58 else
714a562f 59 args.dir = (char *) dirname;
51702635
UD
60 args.stamp = utime;
61
91eee4dd
UD
62 /* Send the ping only to replicas */
63 for (i = 1; i < obj->DI_data.do_servers.do_servers_len; ++i)
43b0e40f 64 __do_niscall2 (&obj->DI_data.do_servers.do_servers_val[i], 1,
91eee4dd 65 NIS_PING, (xdrproc_t) _xdr_ping_args,
43b0e40f 66 (caddr_t) &args, (xdrproc_t) xdr_void,
e852e889 67 (caddr_t) NULL, 0, NULL);
7960f2a7 68 nis_freeresult (res);
51702635 69}