/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2008 Isilon Inc http://www.isilon.com/4* Authors: Doug Rabson <[email protected]>5* Developed with Red Inc: Alfred Perlstein <[email protected]>6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#include <sys/param.h>30#include <sys/kernel.h>31#include <sys/kobj.h>32#include <sys/lock.h>33#include <sys/malloc.h>34#include <sys/mutex.h>3536#include <kgssapi/gssapi.h>37#include <kgssapi/gssapi_impl.h>3839#include "gssd.h"4041OM_uint3242gss_ip_to_dns(OM_uint32 *minor_status,43char *ip_addr,44char *dns_name)45{46struct ip_to_dns_res res;47struct ip_to_dns_args args;48enum clnt_stat stat;49CLIENT *cl;5051*minor_status = 0;52cl = kgss_gssd_client();53if (cl == NULL)54return (GSS_S_FAILURE);5556args.ip_addr.ip_addr_len = strlen(ip_addr);57args.ip_addr.ip_addr_val = mem_alloc(args.ip_addr.ip_addr_len);58memcpy(args.ip_addr.ip_addr_val, ip_addr, args.ip_addr.ip_addr_len);5960bzero(&res, sizeof(res));61stat = gssd_ip_to_dns_1(&args, &res, cl);62CLNT_RELEASE(cl);63if (stat != RPC_SUCCESS) {64*minor_status = stat;65return (GSS_S_FAILURE);66}6768if (res.major_status != GSS_S_COMPLETE) {69*minor_status = res.minor_status;70return (res.major_status);71}7273if (res.dns_name.dns_name_len == 0 ||74res.dns_name.dns_name_len >= NI_MAXHOST) {75*minor_status = 0;76return (GSS_S_FAILURE);77}7879memcpy(dns_name, res.dns_name.dns_name_val, res.dns_name.dns_name_len);80dns_name[res.dns_name.dns_name_len] = '\0';8182return (GSS_S_COMPLETE);83}848586