17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright (c) 1991, 1999 by Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate * All rights reserved.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/errno.h>
297c478bd9Sstevel@tonic-gate #include <setjmp.h>
307c478bd9Sstevel@tonic-gate #include <string.h>
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate #include <sys/socket.h>
337c478bd9Sstevel@tonic-gate #include <sys/sockio.h>
347c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
357c478bd9Sstevel@tonic-gate #include <net/if.h>
367c478bd9Sstevel@tonic-gate #include <netinet/in_systm.h>
377c478bd9Sstevel@tonic-gate #include <netinet/in.h>
387c478bd9Sstevel@tonic-gate #include <rpc/types.h>
397c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
407c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
417c478bd9Sstevel@tonic-gate #include <rpc/clnt.h>
427c478bd9Sstevel@tonic-gate #include <rpc/rpc_msg.h>
437c478bd9Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
447c478bd9Sstevel@tonic-gate #include "snoop.h"
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate extern char *dlc_header;
477c478bd9Sstevel@tonic-gate extern jmp_buf xdr_err;
487c478bd9Sstevel@tonic-gate char *ypbind_error();
497c478bd9Sstevel@tonic-gate char *sum_ypxfrstat();
507c478bd9Sstevel@tonic-gate char *sum_ypmaplist();
517c478bd9Sstevel@tonic-gate void detail_ypmaplist();
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate static void niscall(int);
547c478bd9Sstevel@tonic-gate static void nisreply(int);
557c478bd9Sstevel@tonic-gate static int detail_ypstat(void);
567c478bd9Sstevel@tonic-gate static int sum_ypstat(char *);
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate * Defines missing from 5.0 yp_prot.h
607c478bd9Sstevel@tonic-gate */
617c478bd9Sstevel@tonic-gate #define YPBINDPROG ((ulong_t)100007)
627c478bd9Sstevel@tonic-gate #define YPBINDVERS ((ulong_t)2)
637c478bd9Sstevel@tonic-gate #define YPBINDVERS_ORIG ((ulong_t)1)
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate /* Procedure symbols */
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate #define YPBINDPROC_NULL ((ulong_t)0)
687c478bd9Sstevel@tonic-gate #define YPBINDPROC_DOMAIN ((ulong_t)1)
697c478bd9Sstevel@tonic-gate #define YPBINDPROC_SETDOM ((ulong_t)2)
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate #define YPBIND_ERR_ERR 1 /* Internal error */
727c478bd9Sstevel@tonic-gate #define YPBIND_ERR_NOSERV 2 /* No bound server for passed domain */
737c478bd9Sstevel@tonic-gate #define YPBIND_ERR_RESC 3 /* System resource allocation failure */
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate static char *procnames_bind_short[] = {
777c478bd9Sstevel@tonic-gate "NULL", /* 0 */
787c478bd9Sstevel@tonic-gate "DOMAIN", /* 1 */
797c478bd9Sstevel@tonic-gate "SETDOMAIN", /* 2 */
807c478bd9Sstevel@tonic-gate };
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate static char *procnames_bind_long[] = {
837c478bd9Sstevel@tonic-gate "Null procedure", /* 0 */
847c478bd9Sstevel@tonic-gate "Get domain name", /* 1 */
857c478bd9Sstevel@tonic-gate "Set domain name", /* 2 */
867c478bd9Sstevel@tonic-gate };
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gate static char *procnames_short[] = {
897c478bd9Sstevel@tonic-gate "NULL", /* 0 */
907c478bd9Sstevel@tonic-gate "DOMAIN", /* 1 */
917c478bd9Sstevel@tonic-gate "DOMAIN_NONACK", /* 2 */
927c478bd9Sstevel@tonic-gate "MATCH", /* 3 */
937c478bd9Sstevel@tonic-gate "FIRST", /* 4 */
947c478bd9Sstevel@tonic-gate "NEXT", /* 5 */
957c478bd9Sstevel@tonic-gate "XFR", /* 6 */
967c478bd9Sstevel@tonic-gate "CLEAR", /* 7 */
977c478bd9Sstevel@tonic-gate "ALL", /* 8 */
987c478bd9Sstevel@tonic-gate "MASTER", /* 9 */
997c478bd9Sstevel@tonic-gate "ORDER", /* 10 */
1007c478bd9Sstevel@tonic-gate "MAPLIST", /* 11 */
1017c478bd9Sstevel@tonic-gate "NEWXFR", /* 12 */
1027c478bd9Sstevel@tonic-gate };
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate #define MAXPROC_BIND 2
1057c478bd9Sstevel@tonic-gate #define MAXPROC 12
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate static char *procnames_long[] = {
1087c478bd9Sstevel@tonic-gate "Null procedure", /* 0 */
1097c478bd9Sstevel@tonic-gate "Verify domain support", /* 1 */
1107c478bd9Sstevel@tonic-gate "Verify domain support (broadcast)", /* 2 */
1117c478bd9Sstevel@tonic-gate "Return value of a key", /* 3 */
1127c478bd9Sstevel@tonic-gate "Return first key-value pair in map", /* 4 */
1137c478bd9Sstevel@tonic-gate "Return next key-value pair in map", /* 5 */
1147c478bd9Sstevel@tonic-gate "Request map update (old)", /* 6 */
1157c478bd9Sstevel@tonic-gate "Close current map on server", /* 7 */
1167c478bd9Sstevel@tonic-gate "Get all key-value pairs in map", /* 8 */
1177c478bd9Sstevel@tonic-gate "Get master server", /* 9 */
1187c478bd9Sstevel@tonic-gate "Get order", /* 10 */
1197c478bd9Sstevel@tonic-gate "Return list of supported maps", /* 11 */
1207c478bd9Sstevel@tonic-gate "Request map update", /* 12 */
1217c478bd9Sstevel@tonic-gate };
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate void
interpret_nisbind(int flags,int type,int xid,int vers,int proc,char * data,int len)124*09a9b1acSToomas Soome interpret_nisbind(int flags, int type, int xid, int vers, int proc, char *data,
125*09a9b1acSToomas Soome int len)
1267c478bd9Sstevel@tonic-gate {
1277c478bd9Sstevel@tonic-gate char *line;
1287c478bd9Sstevel@tonic-gate char buff[YPMAXDOMAIN + 1];
1297c478bd9Sstevel@tonic-gate unsigned int status;
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC_BIND)
1327c478bd9Sstevel@tonic-gate return;
1337c478bd9Sstevel@tonic-gate
1347c478bd9Sstevel@tonic-gate if (flags & F_SUM) {
1357c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
1367c478bd9Sstevel@tonic-gate return;
1377c478bd9Sstevel@tonic-gate }
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate line = get_sum_line();
1407c478bd9Sstevel@tonic-gate
1417c478bd9Sstevel@tonic-gate if (type == CALL) {
142*09a9b1acSToomas Soome (void) sprintf(line, "NISBIND C %s",
143*09a9b1acSToomas Soome procnames_bind_short[proc]);
1447c478bd9Sstevel@tonic-gate line += strlen(line);
1457c478bd9Sstevel@tonic-gate switch (proc) {
1467c478bd9Sstevel@tonic-gate case YPBINDPROC_NULL:
1477c478bd9Sstevel@tonic-gate break;
1487c478bd9Sstevel@tonic-gate case YPBINDPROC_DOMAIN:
1497c478bd9Sstevel@tonic-gate (void) sprintf(line, " %s",
150*09a9b1acSToomas Soome getxdr_string(buff, YPMAXDOMAIN));
1517c478bd9Sstevel@tonic-gate break;
1527c478bd9Sstevel@tonic-gate case YPBINDPROC_SETDOM:
1537c478bd9Sstevel@tonic-gate (void) sprintf(line, " %s",
154*09a9b1acSToomas Soome getxdr_string(buff, YPMAXDOMAIN));
1557c478bd9Sstevel@tonic-gate break;
1567c478bd9Sstevel@tonic-gate default:
1577c478bd9Sstevel@tonic-gate break;
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate check_retransmit(line, xid);
1607c478bd9Sstevel@tonic-gate } else {
1617c478bd9Sstevel@tonic-gate (void) sprintf(line, "NISBIND R %s ",
162*09a9b1acSToomas Soome procnames_bind_short[proc]);
1637c478bd9Sstevel@tonic-gate line += strlen(line);
1647c478bd9Sstevel@tonic-gate switch (proc) {
1657c478bd9Sstevel@tonic-gate case YPBINDPROC_NULL:
1667c478bd9Sstevel@tonic-gate break;
1677c478bd9Sstevel@tonic-gate case YPBINDPROC_DOMAIN:
1687c478bd9Sstevel@tonic-gate status = getxdr_long();
1697c478bd9Sstevel@tonic-gate if (status == 1) { /* success */
1707c478bd9Sstevel@tonic-gate (void) strcat(line, "OK");
1717c478bd9Sstevel@tonic-gate } else { /* failure */
1727c478bd9Sstevel@tonic-gate status = getxdr_long();
1737c478bd9Sstevel@tonic-gate (void) sprintf(line, "ERROR=%s",
174*09a9b1acSToomas Soome ypbind_error(status));
1757c478bd9Sstevel@tonic-gate }
1767c478bd9Sstevel@tonic-gate break;
1777c478bd9Sstevel@tonic-gate case YPBINDPROC_SETDOM:
1787c478bd9Sstevel@tonic-gate break;
1797c478bd9Sstevel@tonic-gate default:
1807c478bd9Sstevel@tonic-gate break;
1817c478bd9Sstevel@tonic-gate }
1827c478bd9Sstevel@tonic-gate }
1837c478bd9Sstevel@tonic-gate }
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) {
1867c478bd9Sstevel@tonic-gate show_header("NISBIND:",
187*09a9b1acSToomas Soome "Network Information Service Bind", len);
1887c478bd9Sstevel@tonic-gate show_space();
1897c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
1907c478bd9Sstevel@tonic-gate return;
1917c478bd9Sstevel@tonic-gate }
192*09a9b1acSToomas Soome (void) sprintf(get_line(0, 0), "Proc = %d (%s)",
193*09a9b1acSToomas Soome proc, procnames_bind_long[proc]);
1947c478bd9Sstevel@tonic-gate if (type == CALL) {
1957c478bd9Sstevel@tonic-gate switch (proc) {
1967c478bd9Sstevel@tonic-gate case YPBINDPROC_NULL:
1977c478bd9Sstevel@tonic-gate break;
1987c478bd9Sstevel@tonic-gate case YPBINDPROC_DOMAIN:
1997c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN,
200*09a9b1acSToomas Soome "Domain = %s");
2017c478bd9Sstevel@tonic-gate break;
2027c478bd9Sstevel@tonic-gate case YPBINDPROC_SETDOM:
2037c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN,
204*09a9b1acSToomas Soome "Domain = %s");
2057c478bd9Sstevel@tonic-gate (void) showxdr_hex(4, "Address=%s");
2067c478bd9Sstevel@tonic-gate (void) showxdr_hex(2, "Port=%s");
2077c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Version=%lu");
2087c478bd9Sstevel@tonic-gate break;
2097c478bd9Sstevel@tonic-gate default:
2107c478bd9Sstevel@tonic-gate break;
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate } else {
2137c478bd9Sstevel@tonic-gate switch (proc) {
2147c478bd9Sstevel@tonic-gate case YPBINDPROC_NULL:
2157c478bd9Sstevel@tonic-gate break;
2167c478bd9Sstevel@tonic-gate case YPBINDPROC_DOMAIN:
2177c478bd9Sstevel@tonic-gate status = getxdr_u_long();
2187c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
219*09a9b1acSToomas Soome "Status = %lu (%s)",
220*09a9b1acSToomas Soome status,
221*09a9b1acSToomas Soome status == 1 ? "OK":"Fail");
2227c478bd9Sstevel@tonic-gate if (status == 1) {
223*09a9b1acSToomas Soome (void) showxdr_hex(4, "Address=%s");
224*09a9b1acSToomas Soome (void) showxdr_hex(2, "Port=%s");
2257c478bd9Sstevel@tonic-gate } else {
2267c478bd9Sstevel@tonic-gate status = getxdr_u_long();
2277c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
228*09a9b1acSToomas Soome "Error = %lu (%s)", status,
229*09a9b1acSToomas Soome ypbind_error(status));
2307c478bd9Sstevel@tonic-gate }
2317c478bd9Sstevel@tonic-gate break;
2327c478bd9Sstevel@tonic-gate case YPBINDPROC_SETDOM:
2337c478bd9Sstevel@tonic-gate break;
2347c478bd9Sstevel@tonic-gate default:
2357c478bd9Sstevel@tonic-gate break;
2367c478bd9Sstevel@tonic-gate }
2377c478bd9Sstevel@tonic-gate }
2387c478bd9Sstevel@tonic-gate show_trailer();
2397c478bd9Sstevel@tonic-gate }
2407c478bd9Sstevel@tonic-gate }
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gate void
interpret_nis(int flags,int type,int xid,int vers,int proc,char * data,int len)243*09a9b1acSToomas Soome interpret_nis(int flags, int type, int xid, int vers, int proc, char *data,
244*09a9b1acSToomas Soome int len)
2457c478bd9Sstevel@tonic-gate {
2467c478bd9Sstevel@tonic-gate char *line;
2477c478bd9Sstevel@tonic-gate char *dom, *map, *key;
2487c478bd9Sstevel@tonic-gate int transid, status;
2497c478bd9Sstevel@tonic-gate /* buffers are all the same size so we don't have to keep track */
2507c478bd9Sstevel@tonic-gate char buff1[YPMAXRECORD + 1], buff2[YPMAXRECORD + 1];
2517c478bd9Sstevel@tonic-gate char buff3[YPMAXRECORD + 1];
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gate if (flags & F_SUM) {
2547c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
2557c478bd9Sstevel@tonic-gate return;
2567c478bd9Sstevel@tonic-gate }
2577c478bd9Sstevel@tonic-gate
2587c478bd9Sstevel@tonic-gate line = get_sum_line();
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gate if (type == CALL) {
2617c478bd9Sstevel@tonic-gate if (proc > MAXPROC)
2627c478bd9Sstevel@tonic-gate (void) sprintf(line, "NIS C %d", proc);
2637c478bd9Sstevel@tonic-gate else
264*09a9b1acSToomas Soome (void) sprintf(line, "NIS C %s",
265*09a9b1acSToomas Soome procnames_short[proc]);
2667c478bd9Sstevel@tonic-gate line += strlen(line);
2677c478bd9Sstevel@tonic-gate switch (proc) {
2687c478bd9Sstevel@tonic-gate case YPPROC_NULL:
2697c478bd9Sstevel@tonic-gate break;
2707c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN:
2717c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN_NONACK:
2727c478bd9Sstevel@tonic-gate case YPPROC_MAPLIST:
2737c478bd9Sstevel@tonic-gate /* YPMAXDOMAIN > YPMAXMAP */
2747c478bd9Sstevel@tonic-gate (void) sprintf(line, " %s",
275*09a9b1acSToomas Soome getxdr_string(buff1, YPMAXDOMAIN));
2767c478bd9Sstevel@tonic-gate break;
2777c478bd9Sstevel@tonic-gate case YPPROC_FIRST:
2787c478bd9Sstevel@tonic-gate dom = getxdr_string(buff1, YPMAXDOMAIN);
2797c478bd9Sstevel@tonic-gate map = getxdr_string(buff2, YPMAXMAP);
2807c478bd9Sstevel@tonic-gate (void) sprintf(line, " %s", map);
2817c478bd9Sstevel@tonic-gate break;
2827c478bd9Sstevel@tonic-gate case YPPROC_MATCH:
2837c478bd9Sstevel@tonic-gate case YPPROC_NEXT:
2847c478bd9Sstevel@tonic-gate dom = getxdr_string(buff1, YPMAXDOMAIN);
2857c478bd9Sstevel@tonic-gate map = getxdr_string(buff2, YPMAXMAP);
2867c478bd9Sstevel@tonic-gate key = getxdr_string(buff3, YPMAXRECORD);
287*09a9b1acSToomas Soome (void) sprintf(line, " %s in %s", key, map);
2887c478bd9Sstevel@tonic-gate break;
2897c478bd9Sstevel@tonic-gate case YPPROC_NEWXFR:
2907c478bd9Sstevel@tonic-gate case YPPROC_XFR:
2917c478bd9Sstevel@tonic-gate dom = getxdr_string(buff1, YPMAXDOMAIN);
2927c478bd9Sstevel@tonic-gate map = getxdr_string(buff2, YPMAXMAP);
293*09a9b1acSToomas Soome (void) sprintf(line, " map %s in %s", map, dom);
2947c478bd9Sstevel@tonic-gate break;
2957c478bd9Sstevel@tonic-gate case YPPROC_CLEAR:
2967c478bd9Sstevel@tonic-gate break;
2977c478bd9Sstevel@tonic-gate case YPPROC_ALL:
2987c478bd9Sstevel@tonic-gate case YPPROC_MASTER:
2997c478bd9Sstevel@tonic-gate case YPPROC_ORDER:
3007c478bd9Sstevel@tonic-gate dom = getxdr_string(buff1, YPMAXDOMAIN);
3017c478bd9Sstevel@tonic-gate map = getxdr_string(buff2, YPMAXMAP);
302*09a9b1acSToomas Soome (void) sprintf(line, " map %s in %s", map, dom);
3037c478bd9Sstevel@tonic-gate break;
3047c478bd9Sstevel@tonic-gate default:
3057c478bd9Sstevel@tonic-gate break;
3067c478bd9Sstevel@tonic-gate }
3077c478bd9Sstevel@tonic-gate check_retransmit(line, xid);
3087c478bd9Sstevel@tonic-gate } else {
3097c478bd9Sstevel@tonic-gate if (proc > MAXPROC)
3107c478bd9Sstevel@tonic-gate (void) sprintf(line, "NIS R %d ", proc);
3117c478bd9Sstevel@tonic-gate else
3127c478bd9Sstevel@tonic-gate (void) sprintf(line, "NIS R %s ",
313*09a9b1acSToomas Soome procnames_short[proc]);
3147c478bd9Sstevel@tonic-gate line += strlen(line);
3157c478bd9Sstevel@tonic-gate switch (proc) {
3167c478bd9Sstevel@tonic-gate case YPPROC_NULL:
3177c478bd9Sstevel@tonic-gate break;
3187c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN:
3197c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN_NONACK:
3207c478bd9Sstevel@tonic-gate (void) sprintf(line, "%s",
321*09a9b1acSToomas Soome getxdr_long() ? "OK":"Fail");
3227c478bd9Sstevel@tonic-gate break;
3237c478bd9Sstevel@tonic-gate case YPPROC_MATCH:
3247c478bd9Sstevel@tonic-gate (void) sum_ypstat(line);
3257c478bd9Sstevel@tonic-gate break;
3267c478bd9Sstevel@tonic-gate case YPPROC_FIRST:
3277c478bd9Sstevel@tonic-gate case YPPROC_NEXT:
3287c478bd9Sstevel@tonic-gate if (sum_ypstat(line) == YP_TRUE) {
3297c478bd9Sstevel@tonic-gate line += strlen(line);
3307c478bd9Sstevel@tonic-gate (void) getxdr_string(buff1,
331*09a9b1acSToomas Soome YPMAXRECORD);
3327c478bd9Sstevel@tonic-gate (void) sprintf(line, " key=%s",
333*09a9b1acSToomas Soome getxdr_string(buff1,
334*09a9b1acSToomas Soome YPMAXRECORD));
3357c478bd9Sstevel@tonic-gate }
3367c478bd9Sstevel@tonic-gate break;
3377c478bd9Sstevel@tonic-gate case YPPROC_NEWXFR:
3387c478bd9Sstevel@tonic-gate case YPPROC_XFR:
3397c478bd9Sstevel@tonic-gate transid = getxdr_u_long();
3407c478bd9Sstevel@tonic-gate status = getxdr_long();
341*09a9b1acSToomas Soome (void) sprintf(line, "transid=%lu %s", transid,
342*09a9b1acSToomas Soome sum_ypxfrstat(status));
3437c478bd9Sstevel@tonic-gate break;
3447c478bd9Sstevel@tonic-gate case YPPROC_CLEAR:
3457c478bd9Sstevel@tonic-gate break;
3467c478bd9Sstevel@tonic-gate case YPPROC_ALL:
3477c478bd9Sstevel@tonic-gate if (getxdr_u_long()) {
3487c478bd9Sstevel@tonic-gate (void) sum_ypstat(line);
3497c478bd9Sstevel@tonic-gate line += strlen(line);
3507c478bd9Sstevel@tonic-gate (void) sprintf(line, " key=%s",
3517c478bd9Sstevel@tonic-gate getxdr_string(buff1, YPMAXRECORD));
3527c478bd9Sstevel@tonic-gate } else {
353*09a9b1acSToomas Soome (void) sprintf(line, "No more");
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate break;
3567c478bd9Sstevel@tonic-gate case YPPROC_MASTER:
3577c478bd9Sstevel@tonic-gate if (sum_ypstat(line) == YP_TRUE) {
3587c478bd9Sstevel@tonic-gate line += strlen(line);
3597c478bd9Sstevel@tonic-gate (void) sprintf(line, " peer=%s",
360*09a9b1acSToomas Soome getxdr_string(buff1, YPMAXPEER));
3617c478bd9Sstevel@tonic-gate }
3627c478bd9Sstevel@tonic-gate break;
3637c478bd9Sstevel@tonic-gate case YPPROC_ORDER:
3647c478bd9Sstevel@tonic-gate if (sum_ypstat(line) == YP_TRUE) {
3657c478bd9Sstevel@tonic-gate line += strlen(line);
3667c478bd9Sstevel@tonic-gate (void) sprintf(line, " order=%lu",
367*09a9b1acSToomas Soome getxdr_u_long());
3687c478bd9Sstevel@tonic-gate }
3697c478bd9Sstevel@tonic-gate break;
3707c478bd9Sstevel@tonic-gate case YPPROC_MAPLIST:
3717c478bd9Sstevel@tonic-gate if (sum_ypstat(line) == YP_TRUE) {
3727c478bd9Sstevel@tonic-gate line += strlen(line);
3737c478bd9Sstevel@tonic-gate (void) sprintf(line, " %s",
374*09a9b1acSToomas Soome sum_ypmaplist());
3757c478bd9Sstevel@tonic-gate }
3767c478bd9Sstevel@tonic-gate break;
3777c478bd9Sstevel@tonic-gate default:
3787c478bd9Sstevel@tonic-gate break;
3797c478bd9Sstevel@tonic-gate }
3807c478bd9Sstevel@tonic-gate }
3817c478bd9Sstevel@tonic-gate }
3827c478bd9Sstevel@tonic-gate
3837c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) {
3847c478bd9Sstevel@tonic-gate show_header("NIS: ", "Network Information Service", len);
3857c478bd9Sstevel@tonic-gate show_space();
3867c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
3877c478bd9Sstevel@tonic-gate return;
3887c478bd9Sstevel@tonic-gate }
389*09a9b1acSToomas Soome (void) sprintf(get_line(0, 0), "Proc = %d (%s)", proc,
390*09a9b1acSToomas Soome proc > MAXPROC ? "unknown" : procnames_long[proc]);
3917c478bd9Sstevel@tonic-gate if (type == CALL)
3927c478bd9Sstevel@tonic-gate niscall(proc);
3937c478bd9Sstevel@tonic-gate else
3947c478bd9Sstevel@tonic-gate nisreply(proc);
3957c478bd9Sstevel@tonic-gate show_trailer();
3967c478bd9Sstevel@tonic-gate }
3977c478bd9Sstevel@tonic-gate }
3987c478bd9Sstevel@tonic-gate
3997c478bd9Sstevel@tonic-gate /*
4007c478bd9Sstevel@tonic-gate * Print out version 2 NIS call packets
4017c478bd9Sstevel@tonic-gate */
4027c478bd9Sstevel@tonic-gate
4037c478bd9Sstevel@tonic-gate static void
niscall(int proc)404*09a9b1acSToomas Soome niscall(int proc)
4057c478bd9Sstevel@tonic-gate {
4067c478bd9Sstevel@tonic-gate switch (proc) {
4077c478bd9Sstevel@tonic-gate case YPPROC_NULL:
4087c478bd9Sstevel@tonic-gate break;
4097c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN:
4107c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN_NONACK:
4117c478bd9Sstevel@tonic-gate case YPPROC_MAPLIST:
4127c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN, "Domain = %s");
4137c478bd9Sstevel@tonic-gate break;
4147c478bd9Sstevel@tonic-gate case YPPROC_FIRST:
4157c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN, "Domain = %s");
4167c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXMAP, "Map = %s");
4177c478bd9Sstevel@tonic-gate break;
4187c478bd9Sstevel@tonic-gate case YPPROC_MATCH:
4197c478bd9Sstevel@tonic-gate case YPPROC_NEXT:
4207c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN, "Domain = %s");
4217c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXMAP, "Map = %s");
4227c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXRECORD, "Key = %s");
4237c478bd9Sstevel@tonic-gate break;
4247c478bd9Sstevel@tonic-gate case YPPROC_NEWXFR:
4257c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN, "Domain = %s");
4267c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXMAP, "Map = %s");
4277c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Order = %lu");
4287c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXPEER, "Peer = %s");
4297c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Transid = %lu");
4307c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Prog = %lu");
4317c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXPEER, "Name = %s");
4327c478bd9Sstevel@tonic-gate break;
4337c478bd9Sstevel@tonic-gate case YPPROC_XFR:
4347c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN, "Domain = %s");
4357c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXMAP, "Map = %s");
4367c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Order = %lu");
4377c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXPEER, "Peer = %s");
4387c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Transid = %lu");
4397c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Prog = %lu");
4407c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Port = %lu");
4417c478bd9Sstevel@tonic-gate break;
4427c478bd9Sstevel@tonic-gate case YPPROC_CLEAR:
4437c478bd9Sstevel@tonic-gate break;
4447c478bd9Sstevel@tonic-gate case YPPROC_ALL:
4457c478bd9Sstevel@tonic-gate case YPPROC_MASTER:
4467c478bd9Sstevel@tonic-gate case YPPROC_ORDER:
4477c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXDOMAIN, "Domain = %s");
4487c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXMAP, "Map = %s");
4497c478bd9Sstevel@tonic-gate break;
4507c478bd9Sstevel@tonic-gate default:
4517c478bd9Sstevel@tonic-gate break;
4527c478bd9Sstevel@tonic-gate }
4537c478bd9Sstevel@tonic-gate }
4547c478bd9Sstevel@tonic-gate
4557c478bd9Sstevel@tonic-gate /*
4567c478bd9Sstevel@tonic-gate * Print out version 2 NIS reply packets
4577c478bd9Sstevel@tonic-gate */
4587c478bd9Sstevel@tonic-gate
4597c478bd9Sstevel@tonic-gate void
nisreply(int proc)460*09a9b1acSToomas Soome nisreply(int proc)
4617c478bd9Sstevel@tonic-gate {
4627c478bd9Sstevel@tonic-gate unsigned int xfrstat, more;
4637c478bd9Sstevel@tonic-gate
4647c478bd9Sstevel@tonic-gate switch (proc) {
4657c478bd9Sstevel@tonic-gate case YPPROC_NULL:
4667c478bd9Sstevel@tonic-gate break;
4677c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN:
4687c478bd9Sstevel@tonic-gate case YPPROC_DOMAIN_NONACK:
469*09a9b1acSToomas Soome (void) sprintf(get_line(0, 0), "Result=%s",
470*09a9b1acSToomas Soome getxdr_u_long() ? "OK":"Fail");
4717c478bd9Sstevel@tonic-gate break;
4727c478bd9Sstevel@tonic-gate case YPPROC_MATCH:
4737c478bd9Sstevel@tonic-gate (void) detail_ypstat();
4747c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXRECORD, "Value = %s");
4757c478bd9Sstevel@tonic-gate break;
4767c478bd9Sstevel@tonic-gate case YPPROC_FIRST:
4777c478bd9Sstevel@tonic-gate case YPPROC_NEXT:
4787c478bd9Sstevel@tonic-gate (void) detail_ypstat();
4797c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXRECORD, "Value = %s");
4807c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXRECORD, "Key = %s");
4817c478bd9Sstevel@tonic-gate break;
4827c478bd9Sstevel@tonic-gate case YPPROC_NEWXFR:
4837c478bd9Sstevel@tonic-gate case YPPROC_XFR:
4847c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Transid = %lu");
4857c478bd9Sstevel@tonic-gate xfrstat = getxdr_u_long();
486*09a9b1acSToomas Soome (void) sprintf(get_line(0, 0), "Transfer status = %lu (%s)",
487*09a9b1acSToomas Soome xfrstat, sum_ypxfrstat(xfrstat));
4887c478bd9Sstevel@tonic-gate break;
4897c478bd9Sstevel@tonic-gate case YPPROC_CLEAR:
4907c478bd9Sstevel@tonic-gate break;
4917c478bd9Sstevel@tonic-gate case YPPROC_ALL:
4927c478bd9Sstevel@tonic-gate more = getxdr_u_long();
493*09a9b1acSToomas Soome (void) sprintf(get_line(0, 0), "More = %s",
494*09a9b1acSToomas Soome more ? "true" : "false");
4957c478bd9Sstevel@tonic-gate if (more) {
4967c478bd9Sstevel@tonic-gate (void) detail_ypstat();
4977c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXRECORD, "Value = %s");
4987c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXRECORD, "Key = %s");
4997c478bd9Sstevel@tonic-gate }
5007c478bd9Sstevel@tonic-gate break;
5017c478bd9Sstevel@tonic-gate case YPPROC_MASTER:
5027c478bd9Sstevel@tonic-gate (void) detail_ypstat();
5037c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXPEER, "Peer = %s");
504*09a9b1acSToomas Soome break;
5057c478bd9Sstevel@tonic-gate case YPPROC_ORDER:
5067c478bd9Sstevel@tonic-gate (void) detail_ypstat();
5077c478bd9Sstevel@tonic-gate (void) showxdr_u_long("Order=%lu");
5087c478bd9Sstevel@tonic-gate break;
5097c478bd9Sstevel@tonic-gate case YPPROC_MAPLIST:
5107c478bd9Sstevel@tonic-gate (void) detail_ypstat();
5117c478bd9Sstevel@tonic-gate detail_ypmaplist();
5127c478bd9Sstevel@tonic-gate break;
5137c478bd9Sstevel@tonic-gate default:
5147c478bd9Sstevel@tonic-gate break;
5157c478bd9Sstevel@tonic-gate }
5167c478bd9Sstevel@tonic-gate }
5177c478bd9Sstevel@tonic-gate
5187c478bd9Sstevel@tonic-gate char *
sum_ypxfrstat(int status)519*09a9b1acSToomas Soome sum_ypxfrstat(int status)
5207c478bd9Sstevel@tonic-gate {
5217c478bd9Sstevel@tonic-gate static char buff [16];
5227c478bd9Sstevel@tonic-gate
5237c478bd9Sstevel@tonic-gate switch (status) {
5247c478bd9Sstevel@tonic-gate case 1: return ("Success");
5257c478bd9Sstevel@tonic-gate case 2: return ("Master's version not newer");
5267c478bd9Sstevel@tonic-gate case -1: return ("Can't find server for map");
5277c478bd9Sstevel@tonic-gate case -2: return ("No such domain");
5287c478bd9Sstevel@tonic-gate case -3: return ("Resource allocation failure");
5297c478bd9Sstevel@tonic-gate case -4: return ("RPC failure talking to server");
5307c478bd9Sstevel@tonic-gate case -5: return ("Can't get master address");
5317c478bd9Sstevel@tonic-gate case -6: return ("NIS server/map db error");
5327c478bd9Sstevel@tonic-gate case -7: return ("Bad arguments");
5337c478bd9Sstevel@tonic-gate case -8: return ("Local dbm operation failed");
5347c478bd9Sstevel@tonic-gate case -9: return ("Local file I/O operation failed");
5357c478bd9Sstevel@tonic-gate case -10: return ("Map version skew during transfer");
5367c478bd9Sstevel@tonic-gate case -11: return ("Can't send clear req to local ypserv");
5377c478bd9Sstevel@tonic-gate case -12: return ("No local order number in map");
5387c478bd9Sstevel@tonic-gate case -13: return ("Transfer error");
5397c478bd9Sstevel@tonic-gate case -14: return ("Transfer request refused");
5407c478bd9Sstevel@tonic-gate default:
5417c478bd9Sstevel@tonic-gate (void) sprintf(buff, "(%d)", status);
5427c478bd9Sstevel@tonic-gate return (buff);
5437c478bd9Sstevel@tonic-gate }
5447c478bd9Sstevel@tonic-gate /* NOTREACHED */
5457c478bd9Sstevel@tonic-gate }
5467c478bd9Sstevel@tonic-gate
5477c478bd9Sstevel@tonic-gate static int
sum_ypstat(char * line)548*09a9b1acSToomas Soome sum_ypstat(char *line)
5497c478bd9Sstevel@tonic-gate {
5507c478bd9Sstevel@tonic-gate ulong_t status;
5517c478bd9Sstevel@tonic-gate char *str;
5527c478bd9Sstevel@tonic-gate char buff[16];
5537c478bd9Sstevel@tonic-gate
5547c478bd9Sstevel@tonic-gate status = getxdr_u_long();
5557c478bd9Sstevel@tonic-gate switch (status) {
5567c478bd9Sstevel@tonic-gate case YP_TRUE: str = "OK"; break;
5577c478bd9Sstevel@tonic-gate case YP_NOMORE: str = "No more entries"; break;
5587c478bd9Sstevel@tonic-gate case YP_FALSE: str = "Fail"; break;
5597c478bd9Sstevel@tonic-gate case YP_NOMAP: str = "No such map"; break;
5607c478bd9Sstevel@tonic-gate case YP_NODOM: str = "No such domain"; break;
5617c478bd9Sstevel@tonic-gate case YP_NOKEY: str = "No such key"; break;
5627c478bd9Sstevel@tonic-gate case YP_BADOP: str = "Invalid operation"; break;
5637c478bd9Sstevel@tonic-gate case YP_BADDB: str = "Bad database"; break;
5647c478bd9Sstevel@tonic-gate case YP_YPERR: str = "Server error"; break;
5657c478bd9Sstevel@tonic-gate case YP_BADARGS:str = "Bad args"; break;
5667c478bd9Sstevel@tonic-gate case YP_VERS: str = "Version mismatch"; break;
5677c478bd9Sstevel@tonic-gate default: (void) sprintf(buff, "(%lu)", status);
5687c478bd9Sstevel@tonic-gate str = buff;
5697c478bd9Sstevel@tonic-gate break;
5707c478bd9Sstevel@tonic-gate }
5717c478bd9Sstevel@tonic-gate (void) strcpy(line, str);
5727c478bd9Sstevel@tonic-gate return ((int)status);
5737c478bd9Sstevel@tonic-gate }
5747c478bd9Sstevel@tonic-gate
5757c478bd9Sstevel@tonic-gate static int
detail_ypstat(void)576*09a9b1acSToomas Soome detail_ypstat(void)
5777c478bd9Sstevel@tonic-gate {
5787c478bd9Sstevel@tonic-gate ulong_t status;
5797c478bd9Sstevel@tonic-gate char buff[32];
5807c478bd9Sstevel@tonic-gate
5817c478bd9Sstevel@tonic-gate
5827c478bd9Sstevel@tonic-gate status = sum_ypstat(buff);
583*09a9b1acSToomas Soome (void) sprintf(get_line(0, 0), "Status = %d (%s)", status, buff);
5847c478bd9Sstevel@tonic-gate
5857c478bd9Sstevel@tonic-gate return ((int)status);
5867c478bd9Sstevel@tonic-gate }
5877c478bd9Sstevel@tonic-gate
5887c478bd9Sstevel@tonic-gate char *
sum_ypmaplist(void)589*09a9b1acSToomas Soome sum_ypmaplist(void)
5907c478bd9Sstevel@tonic-gate {
5917c478bd9Sstevel@tonic-gate static char buff[YPMAXMAP + 1];
5927c478bd9Sstevel@tonic-gate int maps = 0;
5937c478bd9Sstevel@tonic-gate
5947c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
5957c478bd9Sstevel@tonic-gate (void) sprintf(buff, "%d+ maps", maps);
5967c478bd9Sstevel@tonic-gate return (buff);
5977c478bd9Sstevel@tonic-gate }
5987c478bd9Sstevel@tonic-gate
5997c478bd9Sstevel@tonic-gate while (getxdr_long()) {
6007c478bd9Sstevel@tonic-gate (void) getxdr_string(buff, YPMAXMAP);
6017c478bd9Sstevel@tonic-gate maps++;
6027c478bd9Sstevel@tonic-gate }
6037c478bd9Sstevel@tonic-gate
6047c478bd9Sstevel@tonic-gate (void) sprintf(buff, "%d maps", maps);
6057c478bd9Sstevel@tonic-gate return (buff);
6067c478bd9Sstevel@tonic-gate }
6077c478bd9Sstevel@tonic-gate
6087c478bd9Sstevel@tonic-gate void
detail_ypmaplist(void)609*09a9b1acSToomas Soome detail_ypmaplist(void)
6107c478bd9Sstevel@tonic-gate {
6117c478bd9Sstevel@tonic-gate int maps = 0;
6127c478bd9Sstevel@tonic-gate
6137c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
6147c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
615*09a9b1acSToomas Soome " %d+ maps. (Frame is incomplete)", maps);
6167c478bd9Sstevel@tonic-gate return;
6177c478bd9Sstevel@tonic-gate }
6187c478bd9Sstevel@tonic-gate
6197c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Map list");
6207c478bd9Sstevel@tonic-gate
6217c478bd9Sstevel@tonic-gate while (getxdr_long()) {
6227c478bd9Sstevel@tonic-gate (void) showxdr_string(YPMAXMAP, " %s");
6237c478bd9Sstevel@tonic-gate maps++;
6247c478bd9Sstevel@tonic-gate }
6257c478bd9Sstevel@tonic-gate
6267c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "%d maps", maps);
6277c478bd9Sstevel@tonic-gate }
6287c478bd9Sstevel@tonic-gate
6297c478bd9Sstevel@tonic-gate char *
ypbind_error(int err)630*09a9b1acSToomas Soome ypbind_error(int err)
6317c478bd9Sstevel@tonic-gate {
6327c478bd9Sstevel@tonic-gate static char buff[16];
6337c478bd9Sstevel@tonic-gate
6347c478bd9Sstevel@tonic-gate switch (err) {
6357c478bd9Sstevel@tonic-gate case YPBIND_ERR_ERR: return ("Internal error");
6367c478bd9Sstevel@tonic-gate case YPBIND_ERR_NOSERV: return ("Internal error");
6377c478bd9Sstevel@tonic-gate case YPBIND_ERR_RESC: return ("Resource allocation fail");
6387c478bd9Sstevel@tonic-gate default:
6397c478bd9Sstevel@tonic-gate (void) sprintf(buff, "(%d)", err);
6407c478bd9Sstevel@tonic-gate return (buff);
6417c478bd9Sstevel@tonic-gate }
6427c478bd9Sstevel@tonic-gate /* NOTREACHED */
6437c478bd9Sstevel@tonic-gate }
644