1179189Sjb/*
2179189Sjb * CDDL HEADER START
3179189Sjb *
4179189Sjb * The contents of this file are subject to the terms of the
5179189Sjb * Common Development and Distribution License (the "License").
6179189Sjb * You may not use this file except in compliance with the License.
7179189Sjb *
8179189Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9179189Sjb * or http://www.opensolaris.org/os/licensing.
10179189Sjb * See the License for the specific language governing permissions
11179189Sjb * and limitations under the License.
12179189Sjb *
13179189Sjb * When distributing Covered Code, include this CDDL HEADER in each
14179189Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15179189Sjb * If applicable, add the following below this CDDL HEADER, with the
16179189Sjb * fields enclosed by brackets "[]" replaced with your own identifying
17179189Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
18179189Sjb *
19179189Sjb * CDDL HEADER END
20179189Sjb *
21179189Sjb * Portions Copyright 2006-2008 John Birrell jb@freebsd.org
22179189Sjb *
23179189Sjb * $FreeBSD$
24179189Sjb */
25179189Sjb
26179189Sjb/*
27179189Sjb * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
28179189Sjb * Use is subject to license terms.
29179189Sjb */
30179189Sjb
31179189Sjb#pragma	D depends_on library ip.d
32179189Sjb#pragma	D depends_on library net.d
33286420Smarkj#pragma	D depends_on module kernel
34249526Spfg#pragma	D depends_on module nfs
35179189Sjb
36179189Sjbtypedef struct nfsv4opinfo {
37179189Sjb	uint64_t noi_xid;	/* unique transation ID */
38179189Sjb	cred_t *noi_cred;	/* credentials for operation */
39179189Sjb	string noi_curpath;	/* current file handle path (if any) */
40179189Sjb} nfsv4opinfo_t;
41179189Sjb
42179189Sjbtypedef struct nfsv4cbinfo {
43179189Sjb	string nci_curpath;	/* current file handle path (if any) */
44179189Sjb} nfsv4cbinfo_t;
45179189Sjb
46179189Sjb#pragma D binding "1.5" translator
47179189Sjbtranslator conninfo_t < struct svc_req *P > {
48179189Sjb	ci_protocol = P->rq_xprt->xp_master->xp_netid == "tcp" ? "ipv4" :
49249600Spfg	    P->rq_xprt->xp_master->xp_netid == "udp" ? "ipv4" :
50179189Sjb	    P->rq_xprt->xp_master->xp_netid == "tcp6" ? "ipv6" :
51249600Spfg	    P->rq_xprt->xp_master->xp_netid == "udp6" ? "ipv6" :
52179189Sjb	    "<unknown>";
53179189Sjb
54249600Spfg	ci_local = (P->rq_xprt->xp_master->xp_netid == "tcp" ||
55249600Spfg	    P->rq_xprt->xp_master->xp_netid == "udp") ?
56249600Spfg	    inet_ntoa(&((struct sockaddr_in *)
57249600Spfg	    P->rq_xprt->xp_xpc.xpc_lcladdr.buf)->sin_addr.S_un.S_addr) :
58249600Spfg	    (P->rq_xprt->xp_master->xp_netid == "tcp6" ||
59249600Spfg	    P->rq_xprt->xp_master->xp_netid == "udp6") ?
60249600Spfg	    inet_ntoa6(&((struct sockaddr_in6 *)
61249600Spfg	    P->rq_xprt->xp_xpc.xpc_lcladdr.buf)->sin6_addr) :
62249600Spfg	    "unknown";
63179189Sjb
64249600Spfg	ci_remote = (P->rq_xprt->xp_master->xp_netid == "tcp" ||
65249600Spfg	    P->rq_xprt->xp_master->xp_netid == "udp") ?
66249600Spfg	    inet_ntoa(&((struct sockaddr_in *)
67249600Spfg	    P->rq_xprt->xp_xpc.xpc_rtaddr.buf)->sin_addr.S_un.S_addr) :
68249600Spfg	    (P->rq_xprt->xp_master->xp_netid == "tcp6" ||
69249600Spfg	    P->rq_xprt->xp_master->xp_netid == "udp6") ?
70249600Spfg	    inet_ntoa6(&((struct sockaddr_in6 *)
71249600Spfg	    P->rq_xprt->xp_xpc.xpc_rtaddr.buf)->sin6_addr) :
72249600Spfg	    "unknown";
73179189Sjb};
74179189Sjb
75179189Sjb#pragma D binding "1.5" translator
76249600Spfgtranslator conninfo_t < rfs4_client_t *P > {
77249600Spfg	ci_protocol = (P->rc_addr.ss_family == AF_INET) ? "ipv4" : "ipv6";
78179189Sjb
79249600Spfg	ci_local = "<unknown>";
80179189Sjb
81249600Spfg	ci_remote = (P->rc_addr.ss_family == AF_INET) ?
82249600Spfg	    inet_ntoa((ipaddr_t *)
83249600Spfg	    &((struct sockaddr_in *)&P->rc_addr)->sin_addr) :
84249600Spfg	    inet_ntoa6(&((struct sockaddr_in6 *)&P->rc_addr)->sin6_addr);
85179189Sjb};
86179189Sjb
87179189Sjb#pragma D binding "1.5" translator
88249600Spfgtranslator nfsv4cbinfo_t < rfs4_deleg_state_t *P > {
89249600Spfg	nci_curpath = (P->rds_finfo->rf_vp == NULL) ? "<unknown>" :
90249600Spfg	    P->rds_finfo->rf_vp->v_path;
91179189Sjb};
92249600Spfg
93249600Spfgtypedef struct nfsv3opinfo {
94249600Spfg	uint64_t noi_xid;	/* unique transation ID */
95249600Spfg	cred_t *noi_cred;	/* credentials for operation */
96249600Spfg	string noi_curpath;	/* current file handle path (if any) */
97249600Spfg} nfsv3opinfo_t;
98249600Spfg
99249600Spfgtypedef struct nfsv3oparg nfsv3oparg_t;
100249600Spfg
101249600Spfg#pragma D binding "1.5" translator
102249600Spfgtranslator nfsv3opinfo_t < nfsv3oparg_t *P > {
103249600Spfg	noi_xid = ((struct svc_req *)arg0)->rq_xprt->xp_xid;
104249600Spfg	noi_cred = (cred_t *)arg1;
105249600Spfg	noi_curpath = (arg2 == 0 || ((vnode_t *)arg2)->v_path == NULL) ?
106249600Spfg	    "<unknown>" : ((vnode_t *)arg2)->v_path;
107249600Spfg};
108