xref: /titanic_51/usr/src/lib/libads/common/poke.c (revision dc32d872cbeb56532bcea030255db9cd79bac7da)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
14  */
15 
16 /*
17  * Private API to force DC Rediscovery.
18  */
19 
20 #include <stdlib.h>
21 #include <string.h>
22 #include <smb/nterror.h>
23 #include <arpa/inet.h>
24 #include "dsgetdc.h"
25 #include "ads_priv.h"
26 #include <assert.h>
27 
28 static struct timeval TIMEOUT = { 15, 0 };
29 
30 int
31 _DsForceRediscovery(char *domain, int flags)
32 {
33 	DsForceRediscoveryArgs args;
34 	CLIENT *clnt = NULL;
35 	enum clnt_stat clstat;
36 	int res;
37 
38 	(void) memset(&args, 0, sizeof (args));
39 	args.Flags = flags;
40 	args.DomainName = domain;
41 
42 	/*
43 	 * Call the ADS deamon.
44 	 */
45 	clnt = clnt_door_create(ADSPRIV_PROGRAM, ADSPRIV_V1, ADSPRIV_MAX_XFER);
46 	if (clnt == NULL)
47 		return (RPC_S_NOT_LISTENING);
48 
49 	clstat = clnt_call(clnt, ADSPRIV_ForceRediscovery,
50 	    (xdrproc_t)xdr_DsForceRediscoveryArgs, (caddr_t)&args,
51 	    (xdrproc_t)xdr_int, (caddr_t)&res, TIMEOUT);
52 
53 	clnt_destroy(clnt);
54 	if (clstat != RPC_SUCCESS)
55 		return (RPC_S_CALL_FAILED);
56 
57 	return (res);
58 }
59