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 /*
232e3b6467Skcpoon  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
242e3b6467Skcpoon  * Use is subject to license terms.
257d897698SMilan Jurik  * Copyright 2012 Milan Jurik. All rights reserved.
26*d7c57852SGary Mills  * Copyright 2017 Gary Mills
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/errno.h>
317c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
327c478bd9Sstevel@tonic-gate #include <setjmp.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <rpc/types.h>
357c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
367c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
377c478bd9Sstevel@tonic-gate #include <rpc/clnt.h>
387c478bd9Sstevel@tonic-gate #include <rpc/rpc_msg.h>
397c478bd9Sstevel@tonic-gate #include <rpc/rpcsec_gss.h>
407c478bd9Sstevel@tonic-gate #include <string.h>
417c478bd9Sstevel@tonic-gate #include "snoop.h"
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate extern jmp_buf xdr_err;
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate struct cache_struct *find_xid();
467c478bd9Sstevel@tonic-gate char *nameof_prog(int prog);
472e3b6467Skcpoon static void print_rpc_gss_init_arg(int, struct cache_struct *);
482e3b6467Skcpoon static void print_rpc_gss_init_res(int);
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate char *
rpcsec_gss_proc_to_string(unsigned int proc)517c478bd9Sstevel@tonic-gate rpcsec_gss_proc_to_string(unsigned int proc)
527c478bd9Sstevel@tonic-gate {
537c478bd9Sstevel@tonic-gate 	switch (proc) {
547c478bd9Sstevel@tonic-gate 	case RPCSEC_GSS_DATA:	return "RPCSEC_GSS_DATA"; break;
557c478bd9Sstevel@tonic-gate 	case RPCSEC_GSS_INIT:	return "RPCSEC_GSS_INIT"; break;
567c478bd9Sstevel@tonic-gate 	case RPCSEC_GSS_CONTINUE_INIT:
577c478bd9Sstevel@tonic-gate 				return ("RPCSEC_GSS_CONTINUE_INIT");
587c478bd9Sstevel@tonic-gate 	case RPCSEC_GSS_DESTROY:
597c478bd9Sstevel@tonic-gate 				return ("RPCSEC_GSS_DESTROY");
607c478bd9Sstevel@tonic-gate 	default:		return ("unknown");
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	}
637c478bd9Sstevel@tonic-gate }
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate char *
rpcsec_gss_service_to_string(rpc_gss_service_t service)677c478bd9Sstevel@tonic-gate rpcsec_gss_service_to_string(rpc_gss_service_t service)
687c478bd9Sstevel@tonic-gate {
697c478bd9Sstevel@tonic-gate 	switch (service) {
707c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_none:	return "none"; break;
717c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_integrity: return "integrity"; break;
727c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_privacy: return "privacy"; break;
737c478bd9Sstevel@tonic-gate 	default:		return "unknown";	  break;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 	}
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  *  Print detailed RPCSEC_GSS cred data.
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate void
print_rpcsec_gss_cred(int xid,int authlen)827c478bd9Sstevel@tonic-gate print_rpcsec_gss_cred(int xid, int authlen)
837c478bd9Sstevel@tonic-gate {
847c478bd9Sstevel@tonic-gate 	unsigned int seq_num;
857c478bd9Sstevel@tonic-gate 	unsigned int handle_len;
867c478bd9Sstevel@tonic-gate 	unsigned int rpcsec_gss_ver;
877c478bd9Sstevel@tonic-gate 	rpc_gss_service_t rpcsec_gss_service;
887c478bd9Sstevel@tonic-gate 	unsigned int rpcsec_gss_proc;
897c478bd9Sstevel@tonic-gate 	char *handle, *line;
907c478bd9Sstevel@tonic-gate 	struct cache_struct *x;
917c478bd9Sstevel@tonic-gate 	int pos;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 	pos = getxdr_pos();
947c478bd9Sstevel@tonic-gate 	rpcsec_gss_ver = getxdr_u_long();
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate 	/* see if we know this version or not */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate 	if (rpcsec_gss_ver != 1) {
997c478bd9Sstevel@tonic-gate 		(void) showxdr_hex(authlen, "[%s]");
1007c478bd9Sstevel@tonic-gate 		return;
1017c478bd9Sstevel@tonic-gate 	}
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	rpcsec_gss_proc   = getxdr_u_long();
1047c478bd9Sstevel@tonic-gate 	seq_num    = getxdr_u_long();
1057c478bd9Sstevel@tonic-gate 	rpcsec_gss_service    = getxdr_enum();
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
1087d897698SMilan Jurik 	    "   version = %u",  rpcsec_gss_ver);
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
1117d897698SMilan Jurik 	    "   gss control procedure = %u (%s)",
1127d897698SMilan Jurik 	    rpcsec_gss_proc,
1137d897698SMilan Jurik 	    rpcsec_gss_proc_to_string(rpcsec_gss_proc));
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
1167d897698SMilan Jurik 	    "   sequence num = %u", seq_num);
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
1197c478bd9Sstevel@tonic-gate 	    "   service = %d (%s)", rpcsec_gss_service,
1207c478bd9Sstevel@tonic-gate 	    rpcsec_gss_service_to_string(rpcsec_gss_service));
1217c478bd9Sstevel@tonic-gate 	pos = getxdr_pos();
1227c478bd9Sstevel@tonic-gate 	handle_len = getxdr_u_long();
1237c478bd9Sstevel@tonic-gate 	handle = getxdr_hex(handle_len);
1247c478bd9Sstevel@tonic-gate 	line = get_line(pos, getxdr_pos());
1257c478bd9Sstevel@tonic-gate 	sprintf(line, "   handle: length = %d, data = [%s]",
1267d897698SMilan Jurik 	    handle_len, handle);
1277c478bd9Sstevel@tonic-gate 	x = find_xid(xid);
1287c478bd9Sstevel@tonic-gate 	if (x) {
1297c478bd9Sstevel@tonic-gate 		x->xid_gss_proc    = rpcsec_gss_proc;
1307c478bd9Sstevel@tonic-gate 		x->xid_gss_service = rpcsec_gss_service;
1317c478bd9Sstevel@tonic-gate 	}
1327c478bd9Sstevel@tonic-gate }
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /*
1357c478bd9Sstevel@tonic-gate  *  Based on different RPCSEC_GSS services supported, maybe a
1367c478bd9Sstevel@tonic-gate  *  special handling is needed before printing the arguments.
1377c478bd9Sstevel@tonic-gate  *
1387c478bd9Sstevel@tonic-gate  *  For integrity service : print the sequence number.
1397c478bd9Sstevel@tonic-gate  *  For privacy service : do not print the arguments.
1407c478bd9Sstevel@tonic-gate  */
1417c478bd9Sstevel@tonic-gate int
rpcsec_gss_pre_proto(int type,int flags,int xid,int prog,int vers,int proc)1427c478bd9Sstevel@tonic-gate rpcsec_gss_pre_proto(int type, int flags, int xid,
1437c478bd9Sstevel@tonic-gate 					int prog, int vers, int proc)
1447c478bd9Sstevel@tonic-gate {
1457c478bd9Sstevel@tonic-gate 	int seq;
1467c478bd9Sstevel@tonic-gate 	struct cache_struct *x;
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 	if (! (x = find_xid(xid)))
1497c478bd9Sstevel@tonic-gate 		return (0);
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate 	switch (x->xid_gss_service) {
1527c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_default:
1537c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_none:
1547c478bd9Sstevel@tonic-gate 		break; /* standard call args */
1557c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_integrity:
1567c478bd9Sstevel@tonic-gate 		/* length of rpc_gss_data_t encoded in the databody_integ */
1577c478bd9Sstevel@tonic-gate 		getxdr_u_long();
1587c478bd9Sstevel@tonic-gate 		/* read the seq number */
1597c478bd9Sstevel@tonic-gate 		seq = getxdr_u_long();
1607c478bd9Sstevel@tonic-gate 		if (flags & F_ALLSUM) {
1617c478bd9Sstevel@tonic-gate 			(void) sprintf(get_sum_line(), "%s %c seq_num = %u",
1627d897698SMilan Jurik 			    "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
1637d897698SMilan Jurik 			    seq);
1647c478bd9Sstevel@tonic-gate 		} else if (flags & F_DTAIL) {
1657c478bd9Sstevel@tonic-gate 			sprintf(get_line(0, 0),
1667d897698SMilan Jurik 			    "RPCSEC_GSS data seq_num = %u", seq);
1677c478bd9Sstevel@tonic-gate 			show_space();
1687c478bd9Sstevel@tonic-gate 		}
1697c478bd9Sstevel@tonic-gate 		/* call args follow */
1707c478bd9Sstevel@tonic-gate 		break;
1717c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_privacy: {
1727c478bd9Sstevel@tonic-gate 		char *progname = nameof_prog(prog);
1737c478bd9Sstevel@tonic-gate 		char prognum[32];
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 		if (*progname == '?') {
1767c478bd9Sstevel@tonic-gate 			sprintf(prognum, "%d", prog);
1777c478bd9Sstevel@tonic-gate 			progname = prognum;
1787c478bd9Sstevel@tonic-gate 		}
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate 		if (flags & F_SUM || flags & F_ALLSUM) {
1817d897698SMilan Jurik 			(void) sprintf(get_sum_line(),
1827d897698SMilan Jurik 			    "%s %c %s ver(%d) proc(%d) (data encrypted) ",
1837d897698SMilan Jurik 			    "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
1847d897698SMilan Jurik 			    progname, vers, proc);
1857c478bd9Sstevel@tonic-gate 		} else if (flags & F_DTAIL) {
1867d897698SMilan Jurik 			unsigned int args_len;
1877d897698SMilan Jurik 
1887d897698SMilan Jurik 			args_len = getxdr_u_long();
1897d897698SMilan Jurik 			sprintf(get_line(0, 0),
1907d897698SMilan Jurik 			    "RPCSEC_GSS %s ver(%d) proc(%d)",
1917d897698SMilan Jurik 			    progname, vers, proc);
1927d897698SMilan Jurik 			sprintf(get_line(0, 0),
1937d897698SMilan Jurik 			    "(%s args encrypted, len = %d bytes)",
1947d897698SMilan Jurik 			    type == CALL ? "CALL" : "REPLY", args_len);
1957d897698SMilan Jurik 			show_space();
1967c478bd9Sstevel@tonic-gate 		}
1977c478bd9Sstevel@tonic-gate 		}
1987c478bd9Sstevel@tonic-gate 		return (1);
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate 	default:
2017c478bd9Sstevel@tonic-gate 		break;
2027c478bd9Sstevel@tonic-gate 	}
2037c478bd9Sstevel@tonic-gate 	return (0);
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate  *  Based on different RPCSEC_GSS services supported, maybe a
2087c478bd9Sstevel@tonic-gate  *  special handling is needed after printing the arguments.
2097c478bd9Sstevel@tonic-gate  *
2107c478bd9Sstevel@tonic-gate  *  For integrity service : print the checksum.
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate void
rpcsec_gss_post_proto(int flags,int xid)2137c478bd9Sstevel@tonic-gate rpcsec_gss_post_proto(int flags, int xid)
2147c478bd9Sstevel@tonic-gate {
2157c478bd9Sstevel@tonic-gate 	char *line;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 	struct cache_struct *x;
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate 	if (! (x = find_xid(xid)))
2207c478bd9Sstevel@tonic-gate 		return;
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 	switch (x->xid_gss_service) {
2237c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_default:
2247c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_none:
2257c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_privacy:
2267c478bd9Sstevel@tonic-gate 		/* nothing left */
2277c478bd9Sstevel@tonic-gate 		break;
2287c478bd9Sstevel@tonic-gate 	case rpc_gss_svc_integrity:
2297c478bd9Sstevel@tonic-gate 		if (flags & F_ALLSUM) {
2307c478bd9Sstevel@tonic-gate 			line = get_sum_line();
2317c478bd9Sstevel@tonic-gate 			sprintf(line, "RPC RPCSEC_GSS C (checksum)");
2327c478bd9Sstevel@tonic-gate 		} else if (flags & F_DTAIL) {
2337c478bd9Sstevel@tonic-gate 			unsigned int checksum_len;
2347c478bd9Sstevel@tonic-gate 			char *checksum;
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate 			show_header("RPC:  ", "RPCSEC_GSS", 0);
2377c478bd9Sstevel@tonic-gate 			show_space();
2387c478bd9Sstevel@tonic-gate 			checksum_len = getxdr_u_long();
2397c478bd9Sstevel@tonic-gate 			checksum = getxdr_hex(checksum_len);
2407c478bd9Sstevel@tonic-gate 			sprintf(get_line(0, 0),
2417d897698SMilan Jurik 			    "checksum: len = %d", checksum_len);
2427c478bd9Sstevel@tonic-gate 			sprintf(get_line(0, 0), "[%s]", checksum);
2437c478bd9Sstevel@tonic-gate 			show_trailer();
2447c478bd9Sstevel@tonic-gate 		}
2457c478bd9Sstevel@tonic-gate 		break;
2467c478bd9Sstevel@tonic-gate 	default:
2477c478bd9Sstevel@tonic-gate 		break;
2487c478bd9Sstevel@tonic-gate 	}
2497c478bd9Sstevel@tonic-gate }
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate /*
2527c478bd9Sstevel@tonic-gate  *  Print RPCSEC_GSS control procedures protocol data,
2537c478bd9Sstevel@tonic-gate  *  No-op for RPCSEC_GSS_DATA.
2547c478bd9Sstevel@tonic-gate  */
2557c478bd9Sstevel@tonic-gate int
rpcsec_gss_control_proc(int type,int flags,int xid)2567c478bd9Sstevel@tonic-gate rpcsec_gss_control_proc(int type, int flags, int xid)
2577c478bd9Sstevel@tonic-gate {
2587c478bd9Sstevel@tonic-gate 	int seq;
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	struct cache_struct *x;
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 	if (! (x = find_xid(xid)))
2637c478bd9Sstevel@tonic-gate 		return (0);
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	if (x->xid_gss_proc != RPCSEC_GSS_DATA) {
2667c478bd9Sstevel@tonic-gate 		if (flags & F_SUM) {
2677c478bd9Sstevel@tonic-gate 			if (type == CALL) {
2687c478bd9Sstevel@tonic-gate 				(void) sprintf(get_sum_line(), "%s %c %u (%s)",
2697d897698SMilan Jurik 				    "RPC RPCSEC_GSS",
2707d897698SMilan Jurik 				    type == CALL ? 'C' : 'R',
2717d897698SMilan Jurik 				    x->xid_gss_proc,
2727d897698SMilan Jurik 				    rpcsec_gss_proc_to_string(x->xid_gss_proc));
2737c478bd9Sstevel@tonic-gate 			}
2747c478bd9Sstevel@tonic-gate 		} else if (flags & F_DTAIL) {
2757c478bd9Sstevel@tonic-gate 			if (x->xid_gss_proc == RPCSEC_GSS_INIT ||
2767c478bd9Sstevel@tonic-gate 			    x->xid_gss_proc == RPCSEC_GSS_CONTINUE_INIT) {
2777c478bd9Sstevel@tonic-gate 				if (type == CALL) {
2787c478bd9Sstevel@tonic-gate 					print_rpc_gss_init_arg(flags, x);
2797c478bd9Sstevel@tonic-gate 				} else {
2807c478bd9Sstevel@tonic-gate 					print_rpc_gss_init_res(flags);
2817c478bd9Sstevel@tonic-gate 				}
2827c478bd9Sstevel@tonic-gate 			}
2837c478bd9Sstevel@tonic-gate 		}
2847c478bd9Sstevel@tonic-gate 		return (1);
2857c478bd9Sstevel@tonic-gate 	}
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate 	return (0);
2887c478bd9Sstevel@tonic-gate }
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  *  Skip the header RPCSEC_GSS cred data and
2927c478bd9Sstevel@tonic-gate  *  put service and control type in the xid cache.
2937c478bd9Sstevel@tonic-gate  */
2942e3b6467Skcpoon void
extract_rpcsec_gss_cred_info(int xid)2957c478bd9Sstevel@tonic-gate extract_rpcsec_gss_cred_info(int xid)
2967c478bd9Sstevel@tonic-gate {
2977c478bd9Sstevel@tonic-gate 	unsigned int handle_len;
2987c478bd9Sstevel@tonic-gate 	unsigned int rpcsec_gss_ver;
2997c478bd9Sstevel@tonic-gate 	rpc_gss_service_t rpcsec_gss_service;
3007c478bd9Sstevel@tonic-gate 	unsigned int rpcsec_gss_proc;
3017c478bd9Sstevel@tonic-gate 	struct cache_struct *x;
3027c478bd9Sstevel@tonic-gate 
303*d7c57852SGary Mills 	(void) getxdr_u_long();
3047c478bd9Sstevel@tonic-gate 	rpcsec_gss_ver = getxdr_u_long();
3057c478bd9Sstevel@tonic-gate 	/* see if we know this version or not */
3067c478bd9Sstevel@tonic-gate 	if (rpcsec_gss_ver != 1) {
3077c478bd9Sstevel@tonic-gate 		longjmp(xdr_err, 1);
3087c478bd9Sstevel@tonic-gate 	}
3097c478bd9Sstevel@tonic-gate 	rpcsec_gss_proc   = getxdr_u_long();
310*d7c57852SGary Mills 	(void) getxdr_u_long();
3117c478bd9Sstevel@tonic-gate 	rpcsec_gss_service    = getxdr_enum();
3127c478bd9Sstevel@tonic-gate 	/* skip the handle */
3137c478bd9Sstevel@tonic-gate 	xdr_skip(RNDUP(getxdr_u_long()));
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate 	if (x = find_xid(xid)) {
3167c478bd9Sstevel@tonic-gate 		x->xid_gss_service = rpcsec_gss_service;
3177c478bd9Sstevel@tonic-gate 		x->xid_gss_proc = rpcsec_gss_proc;
3187c478bd9Sstevel@tonic-gate 	}
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate }
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /*
3237c478bd9Sstevel@tonic-gate  *  Print the argument data for the RPCSEC_GSS_INIT control procedure.
3247c478bd9Sstevel@tonic-gate  */
3252e3b6467Skcpoon static void
print_rpc_gss_init_arg(int flags,struct cache_struct * x)3262e3b6467Skcpoon print_rpc_gss_init_arg(int flags, struct cache_struct *x)
3277c478bd9Sstevel@tonic-gate {
3287c478bd9Sstevel@tonic-gate 
329*d7c57852SGary Mills 	char  *line;
3307c478bd9Sstevel@tonic-gate 	unsigned int token_len;
3317d897698SMilan Jurik 	int pos = 0;
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate 	/*
3347c478bd9Sstevel@tonic-gate 	 *  see if we need to print out the rpc_gss_init_arg structure
3357c478bd9Sstevel@tonic-gate 	 *  or not.
3367c478bd9Sstevel@tonic-gate 	 */
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 	if (x->xid_gss_proc != RPCSEC_GSS_INIT &&
3397d897698SMilan Jurik 	    x->xid_gss_proc != RPCSEC_GSS_CONTINUE_INIT) {
3407c478bd9Sstevel@tonic-gate 		return;
3417c478bd9Sstevel@tonic-gate 	}
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate 	/* print it */
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
3467d897698SMilan Jurik 	    "RPCSEC_GSS_INIT args:");
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate 	pos = getxdr_pos();
3497c478bd9Sstevel@tonic-gate 	token_len = getxdr_u_long();
350*d7c57852SGary Mills 	(void) getxdr_hex(token_len);
3517c478bd9Sstevel@tonic-gate 	line = get_line(pos, getxdr_pos());
3527d897698SMilan Jurik 	sprintf(line, "   gss token: length = %d, data = [%d bytes]",
3537d897698SMilan Jurik 	    token_len, token_len);
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate 	show_trailer();
3567c478bd9Sstevel@tonic-gate }
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate /*
3597c478bd9Sstevel@tonic-gate  *  Print the results data for the RPCSEC_GSS_INIT control procedure.
3607c478bd9Sstevel@tonic-gate  */
3612e3b6467Skcpoon void
print_rpc_gss_init_res(int flags)3627c478bd9Sstevel@tonic-gate print_rpc_gss_init_res(int flags)
3637c478bd9Sstevel@tonic-gate {
3647c478bd9Sstevel@tonic-gate 
365*d7c57852SGary Mills 	char *handle, *line;
3667c478bd9Sstevel@tonic-gate 	unsigned int token_len, handle_len;
3677c478bd9Sstevel@tonic-gate 	unsigned int major, minor, seq_window;
3687c478bd9Sstevel@tonic-gate 
3697d897698SMilan Jurik 	int pos = 0;
3707c478bd9Sstevel@tonic-gate 	struct cache_struct *x;
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate 	/* print it */
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()), "RPCSEC_GSS_INIT result:");
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate 	pos = getxdr_pos();
3777c478bd9Sstevel@tonic-gate 	handle_len = getxdr_u_long();
3787c478bd9Sstevel@tonic-gate 	handle = getxdr_hex(handle_len);
3797c478bd9Sstevel@tonic-gate 	line = get_line(pos, getxdr_pos());
3807c478bd9Sstevel@tonic-gate 	sprintf(line, "   handle: length = %d, data = [%s]",
3817d897698SMilan Jurik 	    handle_len, handle);
3827c478bd9Sstevel@tonic-gate 	pos = getxdr_pos();
3837c478bd9Sstevel@tonic-gate 	major = getxdr_u_long();
3847c478bd9Sstevel@tonic-gate 	minor = getxdr_u_long();
3857c478bd9Sstevel@tonic-gate 	seq_window = getxdr_u_long();
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
3887d897698SMilan Jurik 	    "   gss_major status = %u", major);
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
3917d897698SMilan Jurik 	    "   gss_minor status = %u", minor);
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate 	(void) sprintf(get_line(pos, getxdr_pos()),
3947d897698SMilan Jurik 	    "   sequence window  = %u", seq_window);
3957c478bd9Sstevel@tonic-gate 	pos = getxdr_pos();
3967c478bd9Sstevel@tonic-gate 	token_len = getxdr_u_long();
397*d7c57852SGary Mills 	(void) getxdr_hex(token_len);
3987c478bd9Sstevel@tonic-gate 	line = get_line(pos, getxdr_pos());
3997c478bd9Sstevel@tonic-gate 	sprintf(line, "   gss token: length = %d, data = [%d bytes]",
4007d897698SMilan Jurik 	    token_len, token_len);
4017c478bd9Sstevel@tonic-gate 	show_trailer();
4027c478bd9Sstevel@tonic-gate }
403