dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / ypcmd / ypserv_resolv_common.c
blobe9b3c2d9af11b76c3da1932bdf674b73510b1074
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Routines used by ypserv
32 #include <rpc/rpc.h>
33 #include <netdb.h>
34 #include <rpcsvc/yp_prot.h>
35 #include <errno.h>
36 #include <sys/types.h>
37 #include "ypserv_resolv_common.h"
39 #ifdef TDRPC
40 extern int sys_nerr;
41 extern char *sys_errlist[];
42 extern int errno;
44 char *
45 strerror(err) /* no 4.1.3 strerror() */
46 int err;
48 if (err > 0 && err < sys_nerr)
49 return (sys_errlist[err]);
50 else
51 return ((char *) NULL);
53 #endif
55 bool_t
56 xdr_ypfwdreq_key4(XDR *xdrs, struct ypfwdreq_key4 *ps)
58 return (xdr_ypmap_wrap_string(xdrs, &ps->map) &&
59 xdr_datum(xdrs, &ps->keydat) &&
60 xdr_u_long(xdrs, &ps->xid) &&
61 xdr_u_long(xdrs, &ps->ip) &&
62 xdr_u_short(xdrs, &ps->port));
66 bool_t
67 xdr_ypfwdreq_key6(XDR *xdrs, struct ypfwdreq_key6 *ps)
69 u_int addrsize = sizeof (struct in6_addr)/sizeof (uint32_t);
70 char **addrp = (caddr_t *)&(ps->addr);
72 return (xdr_ypmap_wrap_string(xdrs, &ps->map) &&
73 xdr_datum(xdrs, &ps->keydat) &&
74 xdr_u_long(xdrs, &ps->xid) &&
75 xdr_array(xdrs, addrp, &addrsize, addrsize,
76 sizeof (uint32_t), xdr_uint32_t) &&
77 xdr_u_short(xdrs, &ps->port));
81 u_long
82 svc_getxid(SVCXPRT *xprt)
84 struct svc_dg_data *su = get_svc_dg_data(xprt);
85 if (su == NULL)
86 return (0);
88 return (su->su_xid);