/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <libintl.h>
#include <rpc/rpc.h>
#include <rpc/auth.h>
#include <rpcsvc/nis.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <libc-lock.h>
#include "nis_xdr.h"
#include "nis_intern.h"
#include <libnsl.h>
#include <shlib-compat.h>
static const struct timeval RPCTIMEOUT = {10, 0};
static const struct timeval UDPTIMEOUT = {5, 0};
extern u_short __pmap_getnisport (struct sockaddr_in *address, u_long program,
u_long version, u_int protocol);
unsigned long int
inetstr2int (const char *str)
{
size_t j = 0;
for (size_t i = 0; str[i] != '\0'; ++i)
if (str[i] == '.' && __builtin_expect (++j == 4, 0))
{
char buffer[i + 1];
buffer[i] = '\0';
return inet_addr (memcpy (buffer, str, i));
}
return inet_addr (str);
}
void
__nisbind_destroy (dir_binding *bind)
{
if (bind->clnt != NULL)
{
if (bind->use_auth)
auth_destroy (bind->clnt->cl_auth);
clnt_destroy (bind->clnt);
}