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