b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross/*
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * This file and its contents are supplied under the terms of the
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * Common Development and Distribution License ("CDDL"), version 1.0.
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * You may only use this file in accordance with the terms of version
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * 1.0 of the CDDL.
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross *
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * A full copy of the text of the CDDL should have accompanied this
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * source. A copy of the CDDL is also available via the Internet at
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * http://www.illumos.org/license/CDDL.
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross */
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross/*
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross */
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross/*
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * Private API to force DC Rediscovery.
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross */
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include <stdlib.h>
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include <string.h>
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include <smb/nterror.h>
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include <arpa/inet.h>
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include "dsgetdc.h"
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include "ads_priv.h"
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include <assert.h>
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Rossstatic struct timeval TIMEOUT = { 15, 0 };
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Rossint
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross_DsForceRediscovery(char *domain, int flags)
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross{
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross DsForceRediscoveryArgs args;
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross CLIENT *clnt = NULL;
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross enum clnt_stat clstat;
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross int res;
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross (void) memset(&args, 0, sizeof (args));
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross args.Flags = flags;
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross args.DomainName = domain;
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross /*
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross * Call the ADS deamon.
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross */
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross clnt = clnt_door_create(ADSPRIV_PROGRAM, ADSPRIV_V1, ADSPRIV_MAX_XFER);
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross if (clnt == NULL)
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross return (RPC_S_NOT_LISTENING);
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross clstat = clnt_call(clnt, ADSPRIV_ForceRediscovery,
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross (xdrproc_t)xdr_DsForceRediscoveryArgs, (caddr_t)&args,
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross (xdrproc_t)xdr_int, (caddr_t)&res, TIMEOUT);
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross clnt_destroy(clnt);
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross if (clstat != RPC_SUCCESS)
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross return (RPC_S_CALL_FAILED);
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross return (res);
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross}