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