summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/ipp/ipp.h
blob: 54b4ca12ace893edfab41411f81d13376b564bdd (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (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 2001-2002 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_IPP_IPP_H
#define	_IPP_IPP_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * IP Policy Framework (IPPF)
 */

#include <sys/types.h>
#include <sys/param.h>
#include <sys/nvpair.h>
#include <sys/stream.h>
#include <sys/kstat.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef	_KERNEL

typedef struct ipp_mod		ipp_mod_t;
typedef int32_t			ipp_mod_id_t;

#define	IPP_MOD_RESERVED	0	/* Upper limit of reserved values */
#define	IPP_MOD_INVAL		-1

typedef	struct ipp_action	ipp_action_t;
typedef	int32_t			ipp_action_id_t;

#define	IPP_ACTION_RESERVED	0	/* Upper limit of reserved values */
#define	IPP_ACTION_INVAL	-1
#define	IPP_ACTION_CONT		-2
#define	IPP_ACTION_DEFER	-3
#define	IPP_ACTION_DROP		-4

#endif	/* _KERNEL */

#define	IPP_ANAME_CONT		"ipp.continue"
#define	IPP_ANAME_DEFER		"ipp.defer"
#define	IPP_ANAME_DROP		"ipp.drop"

typedef enum ipp_flags {
	IPP_DESTROY_REF = 0x00000001
} ipp_flags_t;

#ifdef	_KERNEL

typedef struct ipp_stat		ipp_stat_t;

/*
 * NOTE: Semi-opaque alias for struct ipp_stat_impl in common/ipp/ipp_impl.h
 */
struct ipp_stat {
	void	*ipps_data;
};

#define	IPP_STAT_TAG		0x80

#define	IPP_STAT_INT32		(IPP_STAT_TAG | KSTAT_DATA_INT32)
#define	IPP_STAT_UINT32		(IPP_STAT_TAG | KSTAT_DATA_UINT32)
#define	IPP_STAT_INT64		(IPP_STAT_TAG | KSTAT_DATA_INT64)
#define	IPP_STAT_UINT64		(IPP_STAT_TAG | KSTAT_DATA_UINT64)
#define	IPP_STAT_STRING		(IPP_STAT_TAG | KSTAT_DATA_CHAR)

#define	IPP_STAT_READ		KSTAT_READ
#define	IPP_STAT_WRITE		KSTAT_WRITE

typedef kstat_named_t		ipp_named_t;

typedef	struct ipp_class	ipp_class_t;
typedef	struct ipp_log		ipp_log_t;

typedef struct ipp_packet	ipp_packet_t;

#define	IPPO_REV_1	1
#define	IPPO_REV	IPPO_REV_1	/* interface version */

typedef struct ipp_ops	ipp_ops_t;

struct ipp_ops {
	int	ippo_rev;
	int	(*ippo_action_create)(ipp_action_id_t, nvlist_t **,
	    ipp_flags_t);
	int	(*ippo_action_modify)(ipp_action_id_t, nvlist_t **,
	    ipp_flags_t);
	int	(*ippo_action_destroy)(ipp_action_id_t, ipp_flags_t);
	int	(*ippo_action_info)(ipp_action_id_t, int (*)(nvlist_t *,
	    void *), void *, ipp_flags_t);
	int	(*ippo_action_invoke)(ipp_action_id_t, ipp_packet_t *);
};

/*
 * IPPF client interface
 */

extern int		ipp_list_mods(ipp_mod_id_t **, int *);

extern ipp_mod_id_t	ipp_mod_lookup(const char *);
extern int		ipp_mod_name(ipp_mod_id_t, char **);
extern int		ipp_mod_register(const char *, ipp_ops_t *);
extern int		ipp_mod_unregister(ipp_mod_id_t);
extern int		ipp_mod_list_actions(ipp_mod_id_t, ipp_action_id_t **,
    int *);

extern ipp_action_id_t	ipp_action_lookup(const char *);
extern int		ipp_action_name(ipp_action_id_t, char **);
extern int		ipp_action_mod(ipp_action_id_t, ipp_mod_id_t *);
extern int		ipp_action_create(ipp_mod_id_t, const char *,
    nvlist_t **, ipp_flags_t, ipp_action_id_t *);
extern int		ipp_action_modify(ipp_action_id_t, nvlist_t **,
    ipp_flags_t);
extern int		ipp_action_destroy(ipp_action_id_t, ipp_flags_t);
extern int		ipp_action_info(ipp_action_id_t, int (*)(nvlist_t *,
    void *), void *, ipp_flags_t);
extern void		ipp_action_set_ptr(ipp_action_id_t, void *);
extern void		*ipp_action_get_ptr(ipp_action_id_t);
extern int		ipp_action_ref(ipp_action_id_t,	ipp_action_id_t,
    ipp_flags_t);
extern int		ipp_action_unref(ipp_action_id_t, ipp_action_id_t,
    ipp_flags_t);

extern int		ipp_packet_alloc(ipp_packet_t **, const char *,
    ipp_action_id_t);
extern void		ipp_packet_free(ipp_packet_t *);
extern int		ipp_packet_add_class(ipp_packet_t *, const char *,
    ipp_action_id_t);
extern int		ipp_packet_process(ipp_packet_t **);
extern int		ipp_packet_next(ipp_packet_t *, ipp_action_id_t);
extern void		ipp_packet_set_data(ipp_packet_t *, mblk_t *);
extern mblk_t		*ipp_packet_get_data(ipp_packet_t *);
extern void		ipp_packet_set_private(ipp_packet_t *, void *,
    void (*)(void *));
extern void		*ipp_packet_get_private(ipp_packet_t *);

extern int		ipp_stat_create(ipp_action_id_t, const char *, int,
    int (*)(ipp_stat_t *, void *, int), void *, ipp_stat_t **);
extern void		ipp_stat_install(ipp_stat_t *);
extern void		ipp_stat_destroy(ipp_stat_t *);
extern int		ipp_stat_named_init(ipp_stat_t *, const char *,
    uchar_t, ipp_named_t *);
extern int		ipp_stat_named_op(ipp_named_t *, void *, int);

#endif	/* _KERNEL */

#ifdef __cplusplus
}
#endif

#endif /* _IPP_IPP_H */