dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / cmd-inet / usr.sbin / snoop / snoop_rpcprint.c
blob8d61536e34faa895c61f1b82d844a1fe50c6885f
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <string.h>
27 #include <sys/types.h>
28 #include <sys/tiuser.h>
29 #include <rpc/types.h>
30 #include <rpc/xdr.h>
31 #include <rpc/auth.h>
32 #include <rpc/clnt.h>
33 #include <rpc/rpc_msg.h>
34 #include "snoop.h"
36 #define RPC_TRANSIENT_START 0x40000000
37 #define RPC_TRANSIENT_END 0x5fffffff
39 int rpcsec_gss_control_proc(int type, int flags, int xid);
41 int rpcsec_gss_pre_proto(int type, int flags, int xid,
42 int prog, int vers, int proc);
44 void rpcsec_gss_post_proto(int flags, int xid);
46 void
47 protoprint(flags, type, xid, prog, vers, proc, data, len)
48 ulong_t xid;
49 int flags, type, prog, vers, proc;
50 char *data;
51 int len;
53 char *name;
54 void (*interpreter)(int, int, int, int, int, char *, int);
56 switch (prog) {
57 case 100000: interpreter = interpret_pmap; break;
58 case 100001: interpreter = interpret_rstat; break;
59 case 100003: interpreter = interpret_nfs; break;
60 case 100004: interpreter = interpret_nis; break;
61 case 100005: interpreter = interpret_mount; break;
62 case 100007: interpreter = interpret_nisbind; break;
63 case 100011: interpreter = interpret_rquota; break;
64 case 100021: interpreter = interpret_nlm; break;
65 case 100026: interpreter = interpret_bparam; break;
66 case 100227: interpreter = interpret_nfs_acl; break;
67 case 150006: interpreter = interpret_solarnet_fw; break;
68 default: interpreter = NULL;
72 * if rpc in transient range and proc is 0 or 1, then
73 * guess that it is the nfsv4 callback protocol
75 if (prog >= RPC_TRANSIENT_START && prog <= RPC_TRANSIENT_END &&
76 (proc == 0 || proc == 1))
77 interpreter = interpret_nfs4_cb;
80 * If the RPC header indicates it's using the RPCSEC_GSS_*
81 * control procedure, print it.
83 if (rpcsec_gss_control_proc(type, flags, xid)) {
84 return;
87 if (interpreter == NULL) {
88 if (!(flags & F_SUM))
89 return;
90 name = nameof_prog(prog);
91 if (*name == '?' || strcmp(name, "transient") == 0)
92 return;
93 (void) sprintf(get_sum_line(), "%s %c",
94 name,
95 type == CALL ? 'C' : 'R');
96 } else {
97 /* Pre-processing based on different RPCSEC_GSS services. */
98 if (rpcsec_gss_pre_proto(type, flags, xid, prog, vers, proc))
99 return;
101 (*interpreter) (flags, type, xid, vers, proc, data, len);
103 /* Post-processing based on different RPCSEC_GSS services. */
104 rpcsec_gss_post_proto(flags, xid);