xref: /illumos-gate/usr/src/uts/common/ipp/ipp.h (revision 2d6eb4a5)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_IPP_IPP_H
28*7c478bd9Sstevel@tonic-gate #define	_IPP_IPP_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * IP Policy Framework (IPPF)
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/nvpair.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/stream.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
41*7c478bd9Sstevel@tonic-gate extern "C" {
42*7c478bd9Sstevel@tonic-gate #endif
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate typedef struct ipp_mod		ipp_mod_t;
47*7c478bd9Sstevel@tonic-gate typedef int32_t			ipp_mod_id_t;
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #define	IPP_MOD_RESERVED	0	/* Upper limit of reserved values */
50*7c478bd9Sstevel@tonic-gate #define	IPP_MOD_INVAL		-1
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate typedef	struct ipp_action	ipp_action_t;
53*7c478bd9Sstevel@tonic-gate typedef	int32_t			ipp_action_id_t;
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate #define	IPP_ACTION_RESERVED	0	/* Upper limit of reserved values */
56*7c478bd9Sstevel@tonic-gate #define	IPP_ACTION_INVAL	-1
57*7c478bd9Sstevel@tonic-gate #define	IPP_ACTION_CONT		-2
58*7c478bd9Sstevel@tonic-gate #define	IPP_ACTION_DEFER	-3
59*7c478bd9Sstevel@tonic-gate #define	IPP_ACTION_DROP		-4
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate #define	IPP_ANAME_CONT		"ipp.continue"
64*7c478bd9Sstevel@tonic-gate #define	IPP_ANAME_DEFER		"ipp.defer"
65*7c478bd9Sstevel@tonic-gate #define	IPP_ANAME_DROP		"ipp.drop"
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate typedef enum ipp_flags {
68*7c478bd9Sstevel@tonic-gate 	IPP_DESTROY_REF = 0x00000001
69*7c478bd9Sstevel@tonic-gate } ipp_flags_t;
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate typedef struct ipp_stat		ipp_stat_t;
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate /*
76*7c478bd9Sstevel@tonic-gate  * NOTE: Semi-opaque alias for struct ipp_stat_impl in common/ipp/ipp_impl.h
77*7c478bd9Sstevel@tonic-gate  */
78*7c478bd9Sstevel@tonic-gate struct ipp_stat {
79*7c478bd9Sstevel@tonic-gate 	void	*ipps_data;
80*7c478bd9Sstevel@tonic-gate };
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_TAG		0x80
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_INT32		(IPP_STAT_TAG | KSTAT_DATA_INT32)
85*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_UINT32		(IPP_STAT_TAG | KSTAT_DATA_UINT32)
86*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_INT64		(IPP_STAT_TAG | KSTAT_DATA_INT64)
87*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_UINT64		(IPP_STAT_TAG | KSTAT_DATA_UINT64)
88*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_STRING		(IPP_STAT_TAG | KSTAT_DATA_CHAR)
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_READ		KSTAT_READ
91*7c478bd9Sstevel@tonic-gate #define	IPP_STAT_WRITE		KSTAT_WRITE
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate typedef kstat_named_t		ipp_named_t;
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate typedef	struct ipp_class	ipp_class_t;
96*7c478bd9Sstevel@tonic-gate typedef	struct ipp_log		ipp_log_t;
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate typedef struct ipp_packet	ipp_packet_t;
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate #define	IPPO_REV_1	1
101*7c478bd9Sstevel@tonic-gate #define	IPPO_REV	IPPO_REV_1	/* interface version */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate typedef struct ipp_ops	ipp_ops_t;
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate struct ipp_ops {
106*7c478bd9Sstevel@tonic-gate 	int	ippo_rev;
107*7c478bd9Sstevel@tonic-gate 	int	(*ippo_action_create)(ipp_action_id_t, nvlist_t **,
108*7c478bd9Sstevel@tonic-gate 	    ipp_flags_t);
109*7c478bd9Sstevel@tonic-gate 	int	(*ippo_action_modify)(ipp_action_id_t, nvlist_t **,
110*7c478bd9Sstevel@tonic-gate 	    ipp_flags_t);
111*7c478bd9Sstevel@tonic-gate 	int	(*ippo_action_destroy)(ipp_action_id_t, ipp_flags_t);
112*7c478bd9Sstevel@tonic-gate 	int	(*ippo_action_info)(ipp_action_id_t, int (*)(nvlist_t *,
113*7c478bd9Sstevel@tonic-gate 	    void *), void *, ipp_flags_t);
114*7c478bd9Sstevel@tonic-gate 	int	(*ippo_action_invoke)(ipp_action_id_t, ipp_packet_t *);
115*7c478bd9Sstevel@tonic-gate };
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate /*
118*7c478bd9Sstevel@tonic-gate  * IPPF client interface
119*7c478bd9Sstevel@tonic-gate  */
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate extern int		ipp_list_mods(ipp_mod_id_t **, int *);
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate extern ipp_mod_id_t	ipp_mod_lookup(const char *);
124*7c478bd9Sstevel@tonic-gate extern int		ipp_mod_name(ipp_mod_id_t, char **);
125*7c478bd9Sstevel@tonic-gate extern int		ipp_mod_register(const char *, ipp_ops_t *);
126*7c478bd9Sstevel@tonic-gate extern int		ipp_mod_unregister(ipp_mod_id_t);
127*7c478bd9Sstevel@tonic-gate extern int		ipp_mod_list_actions(ipp_mod_id_t, ipp_action_id_t **,
128*7c478bd9Sstevel@tonic-gate     int *);
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate extern ipp_action_id_t	ipp_action_lookup(const char *);
131*7c478bd9Sstevel@tonic-gate extern int		ipp_action_name(ipp_action_id_t, char **);
132*7c478bd9Sstevel@tonic-gate extern int		ipp_action_mod(ipp_action_id_t, ipp_mod_id_t *);
133*7c478bd9Sstevel@tonic-gate extern int		ipp_action_create(ipp_mod_id_t, const char *,
134*7c478bd9Sstevel@tonic-gate     nvlist_t **, ipp_flags_t, ipp_action_id_t *);
135*7c478bd9Sstevel@tonic-gate extern int		ipp_action_modify(ipp_action_id_t, nvlist_t **,
136*7c478bd9Sstevel@tonic-gate     ipp_flags_t);
137*7c478bd9Sstevel@tonic-gate extern int		ipp_action_destroy(ipp_action_id_t, ipp_flags_t);
138*7c478bd9Sstevel@tonic-gate extern int		ipp_action_info(ipp_action_id_t, int (*)(nvlist_t *,
139*7c478bd9Sstevel@tonic-gate     void *), void *, ipp_flags_t);
140*7c478bd9Sstevel@tonic-gate extern void		ipp_action_set_ptr(ipp_action_id_t, void *);
141*7c478bd9Sstevel@tonic-gate extern void		*ipp_action_get_ptr(ipp_action_id_t);
142*7c478bd9Sstevel@tonic-gate extern int		ipp_action_ref(ipp_action_id_t,	ipp_action_id_t,
143*7c478bd9Sstevel@tonic-gate     ipp_flags_t);
144*7c478bd9Sstevel@tonic-gate extern int		ipp_action_unref(ipp_action_id_t, ipp_action_id_t,
145*7c478bd9Sstevel@tonic-gate     ipp_flags_t);
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate extern int		ipp_packet_alloc(ipp_packet_t **, const char *,
148*7c478bd9Sstevel@tonic-gate     ipp_action_id_t);
149*7c478bd9Sstevel@tonic-gate extern void		ipp_packet_free(ipp_packet_t *);
150*7c478bd9Sstevel@tonic-gate extern int		ipp_packet_add_class(ipp_packet_t *, const char *,
151*7c478bd9Sstevel@tonic-gate     ipp_action_id_t);
152*7c478bd9Sstevel@tonic-gate extern int		ipp_packet_process(ipp_packet_t **);
153*7c478bd9Sstevel@tonic-gate extern int		ipp_packet_next(ipp_packet_t *, ipp_action_id_t);
154*7c478bd9Sstevel@tonic-gate extern void		ipp_packet_set_data(ipp_packet_t *, mblk_t *);
155*7c478bd9Sstevel@tonic-gate extern mblk_t		*ipp_packet_get_data(ipp_packet_t *);
156*7c478bd9Sstevel@tonic-gate extern void		ipp_packet_set_private(ipp_packet_t *, void *,
157*7c478bd9Sstevel@tonic-gate     void (*)(void *));
158*7c478bd9Sstevel@tonic-gate extern void		*ipp_packet_get_private(ipp_packet_t *);
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate extern int		ipp_stat_create(ipp_action_id_t, const char *, int,
161*7c478bd9Sstevel@tonic-gate     int (*)(ipp_stat_t *, void *, int), void *, ipp_stat_t **);
162*7c478bd9Sstevel@tonic-gate extern void		ipp_stat_install(ipp_stat_t *);
163*7c478bd9Sstevel@tonic-gate extern void		ipp_stat_destroy(ipp_stat_t *);
164*7c478bd9Sstevel@tonic-gate extern int		ipp_stat_named_init(ipp_stat_t *, const char *,
165*7c478bd9Sstevel@tonic-gate     uchar_t, ipp_named_t *);
166*7c478bd9Sstevel@tonic-gate extern int		ipp_stat_named_op(ipp_named_t *, void *, int);
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
171*7c478bd9Sstevel@tonic-gate }
172*7c478bd9Sstevel@tonic-gate #endif
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate #endif /* _IPP_IPP_H */
175