xref: /titanic_52/usr/src/uts/common/sys/klpd.h (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_KLPD_H
27 #define	_SYS_KLPD_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/priv.h>
33 #include <sys/procset.h>
34 
35 #ifdef _KERNEL
36 #include <sys/cred.h>
37 #include <sys/sysmacros.h>
38 #include <sys/varargs.h>
39 #endif
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 #define	KLPDCALL_VERS		1
46 
47 #define	KLPDARG_NOMORE		0		/* End of argument List */
48 #define	KLPDARG_NONE		0		/* No argument */
49 #define	KLPDARG_VNODE		1		/* vnode_t * */
50 #define	KLPDARG_INT		2		/* int */
51 #define	KLPDARG_PORT		3		/* int, port number */
52 #define	KLPDARG_TCPPORT		4		/* int, tcp port number */
53 #define	KLPDARG_UDPPORT		5		/* int, udp port number */
54 #define	KLPDARG_SCTPPORT	6		/* int, sctp port number */
55 #define	KLPDARG_SDPPORT		7		/* int, sdp port number */
56 
57 #ifdef _KERNEL
58 
59 struct klpd_reg;
60 struct credklpd;
61 
62 int klpd_reg(int, idtype_t, id_t, priv_set_t *);
63 int klpd_unreg(int, idtype_t, id_t);
64 void klpd_remove(struct klpd_reg **);
65 void klpd_rele(struct klpd_reg *);
66 int klpd_call(const cred_t *, const priv_set_t *, va_list);
67 void crklpd_hold(struct credklpd *);
68 void crklpd_rele(struct credklpd *);
69 
70 #endif /* _KERNEL */
71 
72 typedef struct klpd_head {
73 	uint32_t	klh_vers;		/* Version */
74 	uint32_t	klh_len;		/* Length of full packet */
75 	uint32_t	klh_argoff;		/* Offset of argument */
76 	uint32_t	klh_privoff;		/* Offset of privilege set */
77 } klpd_head_t;
78 
79 #define	KLH_PRIVSET(kh)	((priv_set_t *)(((kh)->klh_privoff == 0 ? NULL : \
80 			(char *)(kh) + (kh)->klh_privoff)))
81 #define	KLH_ARG(kh)	((void *)((kh)->klh_argoff != 0 ? \
82 			(char *)(kh) + (kh)->klh_argoff : NULL))
83 
84 typedef struct klpd_arg {
85 	uint_t	kla_type;
86 	uint_t	kla_dlen;
87 	union {
88 		char	__cdata[1];
89 		int	__idata;
90 		uint_t	__uidata;
91 	} kla_data;
92 } klpd_arg_t;
93 
94 #define	kla_str		kla_data.__cdata
95 #define	kla_int		kla_data.__idata
96 #define	kla_uint	kla_data.__uidata
97 
98 #ifdef	__cplusplus
99 }
100 #endif
101 
102 #endif	/* _SYS_KLPD_H */
103