|
root / base / usr / src / cmd / cmd-inet / usr.sbin / snoop / snoop_rpcprint.c
snoop_rpcprint.c C 107 lines 3.1 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#include <string.h>
#include <sys/types.h>
#include <sys/tiuser.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/clnt.h>
#include <rpc/rpc_msg.h>
#include "snoop.h"

#define	RPC_TRANSIENT_START	0x40000000
#define	RPC_TRANSIENT_END	0x5fffffff

int rpcsec_gss_control_proc(int type, int flags, int xid);

int rpcsec_gss_pre_proto(int type, int flags, int xid,
				int prog, int vers, int proc);

void rpcsec_gss_post_proto(int flags, int xid);

void
protoprint(flags, type, xid, prog, vers, proc, data, len)
	ulong_t xid;
	int flags, type, prog, vers, proc;
	char *data;
	int len;
{
	char *name;
	void (*interpreter)(int, int, int, int, int, char *, int);

	switch (prog) {
	case 100000:	interpreter = interpret_pmap;		break;
	case 100001:	interpreter = interpret_rstat;		break;
	case 100003:	interpreter = interpret_nfs;		break;
	case 100004:	interpreter = interpret_nis;		break;
	case 100005:	interpreter = interpret_mount;		break;
	case 100007:	interpreter = interpret_nisbind;	break;
	case 100011:	interpreter = interpret_rquota;		break;
	case 100021:	interpreter = interpret_nlm;		break;
	case 100026:	interpreter = interpret_bparam;		break;
	case 100227:	interpreter = interpret_nfs_acl;	break;
	case 150006:	interpreter = interpret_solarnet_fw;	break;
	default:	interpreter = NULL;
	}

	/*
	 * if rpc in transient range and proc is 0 or 1, then
	 * guess that it is the nfsv4 callback protocol
	 */
	if (prog >= RPC_TRANSIENT_START && prog <= RPC_TRANSIENT_END &&
	    (proc == 0 || proc == 1))
		interpreter = interpret_nfs4_cb;

	/*
	 *  If the RPC header indicates it's using the RPCSEC_GSS_*
	 *  control procedure, print it.
	 */
	if (rpcsec_gss_control_proc(type, flags, xid)) {
			return;
	}

	if (interpreter == NULL) {
		if (!(flags & F_SUM))
			return;
		name = nameof_prog(prog);
		if (*name == '?' || strcmp(name, "transient") == 0)
			return;
		(void) sprintf(get_sum_line(), "%s %c",
			name,
			type == CALL ? 'C' : 'R');
	} else {
		/* Pre-processing based on different RPCSEC_GSS services. */
		if (rpcsec_gss_pre_proto(type, flags, xid, prog, vers, proc))
			return;

		(*interpreter) (flags, type, xid, vers, proc, data, len);

		/* Post-processing based on different RPCSEC_GSS services. */
		rpcsec_gss_post_proto(flags, xid);
	}
}