Sync ypwhich(1) code with the OpenBSD version that is more modern.

Update the BSD LICENSE and remove the 3rd clause.

Reviewed by:	rodrigc, kib, bapt
Approved by:	bapt (mentor)
Obtained from:	OpenBSD
Differential Revision:	D3249
This commit is contained in:
araujo 2015-08-25 15:27:32 +00:00
parent 3e62b0a263
commit 3ddee62f4a
5 changed files with 514 additions and 77 deletions

View File

@ -1,7 +1,13 @@
# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
# $FreeBSD$
YPSERV=${.CURDIR}/../../usr.sbin/ypserv/common
.PATH: ${YPSERV}
PROG= ypwhich
SRCS= yplib_host.c ypwhich.c
CFLAGS+= -I${YPSERV} -I.
WARNS?= 2

View File

@ -1,5 +1,8 @@
/* $OpenBSD: ypwhich.c,v 1.23 2015/02/08 23:40:35 deraadt Exp $ */
/* $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $ */
/*
* Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -10,9 +13,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -34,13 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/socket.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
@ -51,13 +45,12 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
#define ERR_USAGE 1 /* bad arguments - display 'usage' message */
#define ERR_NOSUCHHOST 2 /* no such host */
#define ERR_NOBINDING 3 /* error from ypbind -- domain not bound */
#define ERR_NOYPBIND 4 /* ypbind not running */
#define ERR_NOMASTER 5 /* could not find master server */
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
extern bool_t xdr_domainname();
#include "yplib_host.h"
static const struct ypalias {
char *alias, *name;
@ -77,10 +70,11 @@ static const struct ypalias {
static void
usage(void)
{
fprintf(stderr, "%s\n%s\n",
"usage: ypwhich [-d domain] [[-t] -m [mname] | host]",
" ypwhich -x");
exit(ERR_USAGE);
fprintf(stderr,
"usage: ypwhich [-t] [-d domain] [[-h] host]\n"
" ypwhich [-t] [-d domain] [-h host] -m [mname]\n"
" ypwhich -x\n");
exit(1);
}
@ -88,26 +82,28 @@ usage(void)
* Like yp_bind except can query a specific host
*/
static int
bind_host(char *dom, struct sockaddr_in *lsin)
bind_host(char *dom, struct sockaddr_in *sin)
{
struct hostent *hent = NULL;
struct ypbind_resp ypbr;
struct in_addr ss_addr;
struct timeval tv;
CLIENT *client;
int sock, r;
struct in_addr ss_addr;
sock = RPC_ANYSOCK;
tv.tv_sec = 15;
tv.tv_usec = 0;
client = clntudp_create(lsin, YPBINDPROG, YPBINDVERS, tv, &sock);
client = clntudp_create(sin, YPBINDPROG, YPBINDVERS, tv, &sock);
if (client == NULL) {
warnx("can't clntudp_create: %s", yperr_string(YPERR_YPBIND));
warnx("host is not bound to a ypmaster");
return (YPERR_YPBIND);
}
tv.tv_sec = 5;
tv.tv_usec = 0;
r = clnt_call(client, YPBINDPROC_DOMAIN,
(xdrproc_t)xdr_domainname, &dom,
(xdrproc_t)xdr_ypbind_resp, &ypbr, tv);
@ -118,37 +114,41 @@ bind_host(char *dom, struct sockaddr_in *lsin)
} else {
if (ypbr.ypbind_status != YPBIND_SUCC_VAL) {
warnx("can't yp_bind: reason: %s",
ypbinderr_string(ypbr.ypbind_respbody.ypbind_error));
yperr_string(ypbr.ypbind_status));
clnt_destroy(client);
return (r);
}
}
clnt_destroy(client);
ss_addr = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr;
/*printf("%08x\n", ss_addr);*/
hent = gethostbyaddr((char *)&ss_addr, sizeof(ss_addr), AF_INET);
if (hent)
memmove(&ss_addr.s_addr, &ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,
sizeof (ss_addr));
hent = gethostbyaddr((char *)&ss_addr.s_addr, sizeof(ss_addr.s_addr),
AF_INET);
if (hent != NULL)
printf("%s\n", hent->h_name);
else
printf("%s\n", inet_ntoa(ss_addr));
return (0);
}
int
main(int argc, char *argv[])
{
char *domnam = NULL, *master;
char *map = NULL;
char *domain, *master, *map = NULL, *host = NULL;
int notrans = 0, mode = 0, c, r, i;
struct ypmaplist *ypml, *y;
struct sockaddr_in sin;
struct hostent *hent;
struct sockaddr_in lsin;
int notrans, mode;
int c, r;
u_int i;
CLIENT *client = NULL;
notrans = mode = 0;
while ((c = getopt(argc, argv, "xd:mt")) != -1)
yp_get_default_domain(&domain);
if (domain == NULL)
errx(1, "YP domain name not set");
while ((c = getopt(argc, argv, "xd:h:mt")) != -1)
switch (c) {
case 'x':
for (i = 0; i < nitems(ypaliases); i++)
@ -156,44 +156,46 @@ main(int argc, char *argv[])
ypaliases[i].alias,
ypaliases[i].name);
exit(0);
case 'h':
host = optarg;
break;
case 'd':
domnam = optarg;
domain = optarg;
break;
case 't':
notrans++;
notrans = 1;
break;
case 'm':
mode++;
mode = 1;
break;
default:
usage();
}
if (domnam == NULL)
yp_get_default_domain(&domnam);
argc -= optind;
argv += optind;
if (mode == 0) {
switch (argc-optind) {
switch (argc) {
case 0:
bzero(&lsin, sizeof lsin);
lsin.sin_family = AF_INET;
lsin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if (bind_host(domnam, &lsin))
exit(ERR_NOBINDING);
if (bind_host(domain, &sin))
exit(1);
break;
case 1:
bzero(&lsin, sizeof lsin);
lsin.sin_family = AF_INET;
if ((lsin.sin_addr.s_addr = inet_addr(argv[optind])) == INADDR_NONE) {
hent = gethostbyname(argv[optind]);
if (!hent)
errx(ERR_NOSUCHHOST, "host %s unknown", argv[optind]);
bcopy((char *)hent->h_addr_list[0],
(char *)&lsin.sin_addr, sizeof lsin.sin_addr);
bzero(&sin, sizeof sin);
sin.sin_family = AF_INET;
if (inet_aton(argv[0], &sin.sin_addr) == 0) {
hent = gethostbyname(argv[0]);
if (!hent) {
errx(1, "host %s unknown",
argv[0]);
}
}
if (bind_host(domnam, &lsin))
exit(ERR_NOBINDING);
if (bind_host(domain, &sin))
exit(1);
break;
default:
usage();
@ -201,57 +203,75 @@ main(int argc, char *argv[])
exit(0);
}
if (argc-optind > 1)
if (argc > 1)
usage();
if (argv[optind]) {
map = argv[optind];
if (host != NULL)
client = yp_bind_host(host, YPPROG, YPVERS, 0, 1);
if (argv[0]) {
map = argv[0];
if (notrans == 0) {
for (i = 0; i < nitems(ypaliases); i++)
if (strcmp(map, ypaliases[i].alias) == 0)
map = ypaliases[i].name;
}
r = yp_master(domnam, map, &master);
if (host != NULL)
r = yp_master_host(client, domain, map, &master);
else
r = yp_master(domain, map, &master);
switch (r) {
case 0:
printf("%s\n", master);
free(master);
break;
case YPERR_YPBIND:
errx(ERR_NOYPBIND, "not running ypbind");
errx(1, "not running ypbind");
default:
errx(ERR_NOMASTER, "can't find master for map %s: reason: %s",
map, yperr_string(r));
errx(1, "can't find master for map %s: reason: %s",
map, yperr_string(r));
}
exit(0);
}
ypml = NULL;
r = yp_maplist(domnam, &ypml);
if (host != NULL)
r = yp_maplist_host(client, domain, &ypml);
else
r = yp_maplist(domain, &ypml);
r = 0;
switch (r) {
case 0:
for (y = ypml; y;) {
for (y = ypml; y; ) {
ypml = y;
r = yp_master(domnam, ypml->ypml_name, &master);
if (host != NULL) {
r = yp_master_host(client,
domain, ypml->map, &master);
} else {
r = yp_master(domain, ypml->map, &master);
}
switch (r) {
case 0:
printf("%s %s\n", ypml->ypml_name, master);
printf("%s %s\n", ypml->map, master);
free(master);
break;
default:
warnx("can't find the master of %s: reason: %s",
ypml->ypml_name, yperr_string(r));
ypml->map, yperr_string(r));
break;
}
y = ypml->ypml_next;
y = ypml->next;
free(ypml);
}
break;
case YPERR_YPBIND:
errx(ERR_NOYPBIND, "not running ypbind");
errx(1, "not running ypbind");
default:
errx(ERR_NOMASTER, "can't get map list for domain %s: reason: %s",
domnam, yperr_string(r));
errx(1, "can't get map list for domain %s: reason: %s",
domain, yperr_string(r));
}
exit(0);
}

View File

@ -1,12 +1,14 @@
# $FreeBSD$
RPCDIR= ${.CURDIR}/../../include/rpcsvc
.PATH: ${RPCDIR}
.PATH: ${RPCDIR} \
${.CURDIR}/common
PROG= ypserv
MAN= ypserv.8 ypinit.8
SRCS= yp_svc.c yp_server.c yp_dblookup.c yp_dnslookup.c \
ypxfr_clnt.c yp.h yp_main.c yp_error.c yp_access.c yp_svc_udp.c
ypxfr_clnt.c yp.h yp_main.c yp_error.c yp_access.c yp_svc_udp.c \
yplib_host.c
CFLAGS+= -DDB_CACHE -DTCP_WRAPPER -I.

View File

@ -0,0 +1,356 @@
/* $OpenBSD: yplib_host.c,v 1.18 2015/01/16 06:40:22 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/file.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
#include "yplib_host.h"
extern int (*ypresp_allfn)(u_long, char *, int, char *, int, void *);
extern void *ypresp_data;
extern bool_t xdr_ypreq_key(), xdr_ypresp_val();
extern bool_t xdr_ypresp_all_seq();
static int _yplib_host_timeout = 10;
CLIENT *
yp_bind_host(char *server, u_long program, u_long version, u_short port,
int usetcp)
{
struct sockaddr_in rsrv_sin;
static CLIENT *client;
struct hostent *h;
struct timeval tv;
int rsrv_sock;
memset(&rsrv_sin, 0, sizeof rsrv_sin);
rsrv_sin.sin_len = sizeof rsrv_sin;
rsrv_sin.sin_family = AF_INET;
rsrv_sock = RPC_ANYSOCK;
if (port != 0)
rsrv_sin.sin_port = htons(port);
if (*server >= '0' && *server <= '9') {
if (inet_aton(server, &rsrv_sin.sin_addr) == 0) {
errx(1, "inet_aton: invalid address %s.",
server);
}
} else {
h = gethostbyname(server);
if (h == NULL) {
errx(1, "gethostbyname: unknown host %s.",
server);
}
rsrv_sin.sin_addr.s_addr = *(u_int32_t *)h->h_addr;
}
tv.tv_sec = 10;
tv.tv_usec = 0;
if (usetcp)
client = clnttcp_create(&rsrv_sin, program, version,
&rsrv_sock, 0, 0);
else
client = clntudp_create(&rsrv_sin, program, version, tv,
&rsrv_sock);
if (client == NULL) {
errx(1, "clntudp_create: no contact with host %s.",
server);
}
return (client);
}
CLIENT *
yp_bind_local(u_long program, u_long version)
{
struct sockaddr_in rsrv_sin;
static CLIENT *client;
struct timeval tv;
int rsrv_sock;
memset(&rsrv_sin, 0, sizeof rsrv_sin);
rsrv_sin.sin_len = sizeof rsrv_sin;
rsrv_sin.sin_family = AF_INET;
rsrv_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
rsrv_sock = RPC_ANYSOCK;
tv.tv_sec = 10;
tv.tv_usec = 0;
client = clntudp_create(&rsrv_sin, program, version, tv, &rsrv_sock);
if (client == NULL) {
errx(1, "clntudp_create: no contact with localhost.");
}
return (client);
}
int
yp_match_host(CLIENT *client, char *indomain, char *inmap, const char *inkey,
int inkeylen, char **outval, int *outvallen)
{
struct ypresp_val yprv;
struct ypreq_key yprk;
struct timeval tv;
int r;
*outval = NULL;
*outvallen = 0;
tv.tv_sec = _yplib_host_timeout;
tv.tv_usec = 0;
yprk.domain = indomain;
yprk.map = inmap;
yprk.key.keydat_val = (char *)inkey;
yprk.key.keydat_len = inkeylen;
memset(&yprv, 0, sizeof yprv);
r = clnt_call(client, YPPROC_MATCH,
(xdrproc_t)xdr_ypreq_key, &yprk,
(xdrproc_t)xdr_ypresp_val, &yprv, tv);
if (r != RPC_SUCCESS)
clnt_perror(client, "yp_match_host: clnt_call");
if ( !(r = ypprot_err(yprv.stat)) ) {
*outvallen = yprv.val.valdat_len;
*outval = malloc(*outvallen + 1);
memcpy(*outval, yprv.val.valdat_val, *outvallen);
(*outval)[*outvallen] = '\0';
}
xdr_free((xdrproc_t)xdr_ypresp_val, (char *)&yprv);
return (r);
}
int
yp_first_host(CLIENT *client, char *indomain, char *inmap, char **outkey,
int *outkeylen, char **outval, int *outvallen)
{
struct ypresp_key_val yprkv;
struct ypreq_nokey yprnk;
struct timeval tv;
int r;
*outkey = *outval = NULL;
*outkeylen = *outvallen = 0;
tv.tv_sec = _yplib_host_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
memset(&yprkv, 0, sizeof yprkv);
r = clnt_call(client, YPPROC_FIRST,
(xdrproc_t)xdr_ypreq_nokey, &yprnk,
(xdrproc_t)xdr_ypresp_key_val, &yprkv, tv);
if (r != RPC_SUCCESS)
clnt_perror(client, "yp_first_host: clnt_call");
if ( !(r = ypprot_err(yprkv.stat)) ) {
*outkeylen = yprkv.key.keydat_len;
*outkey = malloc(*outkeylen+1);
memcpy(*outkey, yprkv.key.keydat_val, *outkeylen);
(*outkey)[*outkeylen] = '\0';
*outvallen = yprkv.val.valdat_len;
*outval = malloc(*outvallen+1);
memcpy(*outval, yprkv.val.valdat_val, *outvallen);
(*outval)[*outvallen] = '\0';
}
xdr_free((xdrproc_t)xdr_ypresp_key_val, (char *)&yprkv);
return (r);
}
int
yp_next_host(CLIENT *client, char *indomain, char *inmap, char *inkey,
int inkeylen, char **outkey, int *outkeylen, char **outval, int *outvallen)
{
struct ypresp_key_val yprkv;
struct ypreq_key yprk;
struct timeval tv;
int r;
*outkey = *outval = NULL;
*outkeylen = *outvallen = 0;
tv.tv_sec = _yplib_host_timeout;
tv.tv_usec = 0;
yprk.domain = indomain;
yprk.map = inmap;
yprk.key.keydat_val = inkey;
yprk.key.keydat_len = inkeylen;
memset(&yprkv, 0, sizeof yprkv);
r = clnt_call(client, YPPROC_NEXT,
(xdrproc_t)xdr_ypreq_key, &yprk,
(xdrproc_t)xdr_ypresp_key_val, &yprkv, tv);
if (r != RPC_SUCCESS)
clnt_perror(client, "yp_next_host: clnt_call");
if ( !(r = ypprot_err(yprkv.stat)) ) {
*outkeylen = yprkv.key.keydat_len;
*outkey = malloc(*outkeylen+1);
memcpy(*outkey, yprkv.key.keydat_val, *outkeylen);
(*outkey)[*outkeylen] = '\0';
*outvallen = yprkv.val.valdat_len;
*outval = malloc(*outvallen+1);
memcpy(*outval, yprkv.val.valdat_val, *outvallen);
(*outval)[*outvallen] = '\0';
}
xdr_free((xdrproc_t)xdr_ypresp_key_val, (char *)&yprkv);
return (r);
}
int
yp_all_host(CLIENT *client, char *indomain, char *inmap,
struct ypall_callback *incallback)
{
struct ypreq_nokey yprnk;
struct timeval tv;
u_long status;
tv.tv_sec = _yplib_host_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
ypresp_allfn = incallback->foreach;
ypresp_data = (void *)incallback->data;
(void) clnt_call(client, YPPROC_ALL,
(xdrproc_t)xdr_ypreq_nokey, &yprnk,
(xdrproc_t)xdr_ypresp_all_seq, &status, tv);
if (status != YP_FALSE)
return ypprot_err(status);
return (0);
}
int
yp_order_host(CLIENT *client, char *indomain, char *inmap, u_int32_t *outorder)
{
struct ypresp_order ypro;
struct ypreq_nokey yprnk;
struct timeval tv;
int r;
tv.tv_sec = _yplib_host_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
memset(&ypro, 0, sizeof ypro);
r = clnt_call(client, YPPROC_ORDER,
(xdrproc_t)xdr_ypreq_nokey, &yprnk,
(xdrproc_t)xdr_ypresp_order, &ypro, tv);
if (r != RPC_SUCCESS)
clnt_perror(client, "yp_order_host: clnt_call");
*outorder = ypro.ordernum;
xdr_free((xdrproc_t)xdr_ypresp_order, (char *)&ypro);
return ypprot_err(ypro.stat);
}
int
yp_master_host(CLIENT *client, char *indomain, char *inmap, char **outname)
{
struct ypresp_master yprm;
struct ypreq_nokey yprnk;
struct timeval tv;
int r;
tv.tv_sec = _yplib_host_timeout;
tv.tv_usec = 0;
yprnk.domain = indomain;
yprnk.map = inmap;
memset(&yprm, 0, sizeof yprm);
r = clnt_call(client, YPPROC_MASTER,
(xdrproc_t)xdr_ypreq_nokey, &yprnk,
(xdrproc_t)xdr_ypresp_master, &yprm, tv);
if (r != RPC_SUCCESS)
clnt_perror(client, "yp_master: clnt_call");
if (!(r = ypprot_err(yprm.stat)))
*outname = strdup(yprm.peer);
xdr_free((xdrproc_t)xdr_ypresp_master, (char *)&yprm);
return (r);
}
int
yp_maplist_host(CLIENT *client, char *indomain, struct ypmaplist **outmaplist)
{
struct ypresp_maplist ypml;
struct timeval tv;
int r;
tv.tv_sec = _yplib_host_timeout;
tv.tv_usec = 0;
memset(&ypml, 0, sizeof ypml);
r = clnt_call(client, YPPROC_MAPLIST,
(xdrproc_t)xdr_domainname, &indomain,
(xdrproc_t)xdr_ypresp_maplist, &ypml, tv);
if (r != RPC_SUCCESS)
clnt_perror(client, "yp_maplist: clnt_call");
*outmaplist = ypml.maps;
/* NO: xdr_free(xdr_ypresp_maplist, &ypml);*/
return ypprot_err(ypml.stat);
}

View File

@ -0,0 +1,53 @@
/* $OpenBSD: yplib_host.h,v 1.8 2003/06/02 04:12:38 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _YPLIB_HOST_H_
#define _YPLIB_HOST_H_
int yp_match_host(CLIENT *client, char *indomain, char *inmap,
const char *inkey, int inkeylen, char **outval, int *outvallen);
int yp_first_host(CLIENT *client, char *indomain, char *inmap,
char **outkey, int *outkeylen, char **outval, int *outvallen);
int yp_next_host(CLIENT *client, char *indomain, char *inmap, char *inkey,
int inkeylen, char **outkey, int *outkeylen, char **outval,
int *outvallen);
int yp_master_host(CLIENT *client, char *indomain, char *inmap,
char **outname);
int yp_order_host(CLIENT *client, char *indomain, char *inmap,
u_int32_t *outorder);
int yp_all_host(CLIENT *client, char *indomain, char *inmap,
struct ypall_callback *incallback);
int yp_maplist_host(CLIENT *client, char *indomain,
struct ypmaplist **outmaplist);
CLIENT *yp_bind_local(u_long program, u_long version);
CLIENT *yp_bind_host(char *server, u_long program, u_long version,
u_short port, int usetcp);
#endif /* _YPLIB_HOST_H_ */