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