10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*4321Scasper * Common Development and Distribution License (the "License").
6*4321Scasper * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*4321Scasper * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23*4321Scasper * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
270Sstevel@tonic-gate
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate * Routines used by ypserv
300Sstevel@tonic-gate */
310Sstevel@tonic-gate
320Sstevel@tonic-gate #include <rpc/rpc.h>
330Sstevel@tonic-gate #include <netdb.h>
340Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
350Sstevel@tonic-gate #include <errno.h>
360Sstevel@tonic-gate #include <sys/types.h>
370Sstevel@tonic-gate #include "ypserv_resolv_common.h"
380Sstevel@tonic-gate
390Sstevel@tonic-gate #ifdef TDRPC
400Sstevel@tonic-gate extern int sys_nerr;
410Sstevel@tonic-gate extern char *sys_errlist[];
420Sstevel@tonic-gate extern int errno;
430Sstevel@tonic-gate
440Sstevel@tonic-gate char *
strerror(err)450Sstevel@tonic-gate strerror(err) /* no 4.1.3 strerror() */
460Sstevel@tonic-gate int err;
470Sstevel@tonic-gate {
480Sstevel@tonic-gate if (err > 0 && err < sys_nerr)
490Sstevel@tonic-gate return (sys_errlist[err]);
500Sstevel@tonic-gate else
510Sstevel@tonic-gate return ((char *) NULL);
520Sstevel@tonic-gate }
530Sstevel@tonic-gate #endif
540Sstevel@tonic-gate
550Sstevel@tonic-gate bool_t
xdr_ypfwdreq_key4(XDR * xdrs,struct ypfwdreq_key4 * ps)560Sstevel@tonic-gate xdr_ypfwdreq_key4(XDR *xdrs, struct ypfwdreq_key4 *ps)
570Sstevel@tonic-gate {
580Sstevel@tonic-gate return (xdr_ypmap_wrap_string(xdrs, &ps->map) &&
590Sstevel@tonic-gate xdr_datum(xdrs, &ps->keydat) &&
600Sstevel@tonic-gate xdr_u_long(xdrs, &ps->xid) &&
610Sstevel@tonic-gate xdr_u_long(xdrs, &ps->ip) &&
620Sstevel@tonic-gate xdr_u_short(xdrs, &ps->port));
630Sstevel@tonic-gate }
640Sstevel@tonic-gate
650Sstevel@tonic-gate
660Sstevel@tonic-gate bool_t
xdr_ypfwdreq_key6(XDR * xdrs,struct ypfwdreq_key6 * ps)670Sstevel@tonic-gate xdr_ypfwdreq_key6(XDR *xdrs, struct ypfwdreq_key6 *ps)
680Sstevel@tonic-gate {
690Sstevel@tonic-gate u_int addrsize = sizeof (struct in6_addr)/sizeof (uint32_t);
700Sstevel@tonic-gate char **addrp = (caddr_t *)&(ps->addr);
710Sstevel@tonic-gate
720Sstevel@tonic-gate return (xdr_ypmap_wrap_string(xdrs, &ps->map) &&
730Sstevel@tonic-gate xdr_datum(xdrs, &ps->keydat) &&
740Sstevel@tonic-gate xdr_u_long(xdrs, &ps->xid) &&
750Sstevel@tonic-gate xdr_array(xdrs, addrp, &addrsize, addrsize,
760Sstevel@tonic-gate sizeof (uint32_t), xdr_uint32_t) &&
770Sstevel@tonic-gate xdr_u_short(xdrs, &ps->port));
780Sstevel@tonic-gate }
790Sstevel@tonic-gate
800Sstevel@tonic-gate
810Sstevel@tonic-gate u_long
svc_getxid(SVCXPRT * xprt)820Sstevel@tonic-gate svc_getxid(SVCXPRT *xprt)
830Sstevel@tonic-gate {
84*4321Scasper struct svc_dg_data *su = get_svc_dg_data(xprt);
850Sstevel@tonic-gate if (su == NULL)
860Sstevel@tonic-gate return (0);
870Sstevel@tonic-gate
880Sstevel@tonic-gate return (su->su_xid);
890Sstevel@tonic-gate }
90