xref: /titanic_50/usr/src/uts/common/ipp/ipgpc/classifier.h (revision 2df1fe9ca32bb227b9158c67f5c00b54c20b10fd)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _IPP_IPGPC_CLASSIFIER_H
28 #define	_IPP_IPGPC_CLASSIFIER_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/cmn_err.h>
34 #include <ipp/ipgpc/filters.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /* Header file for classifier implementation for ipgpc */
41 
42 #define	IPGPC_DEBUG
43 
44 #ifdef IPGPC_DEBUG
45 #include <sys/debug.h>
46 
47 #define	ipgpc0dbg(a)	printf a
48 #define	ipgpc1dbg(a)	if (ipgpc_debug > 2) printf a
49 #define	ipgpc2dbg(a)	if (ipgpc_debug > 3) printf a
50 #define	ipgpc3dbg(a)	if (ipgpc_debug > 4) printf a
51 #define	ipgpc4dbg(a)	if (ipgpc_debug > 5) printf a
52 #else
53 #define	ipgpc0dbg(a)		/*  */
54 #define	ipgpc1dbg(a)		/*  */
55 #define	ipgpc2dbg(a)		/*  */
56 #define	ipgpc3dbg(a)		/*  */
57 #define	ipgpc4dbg(a)		/*  */
58 #endif /* IPGPC_DEBUG */
59 
60 #define	BUMP_STATS(x)		++(x)
61 #define	SET_STATS(x, y)		x = y
62 #define	UPDATE_STATS(x, y)	x += y
63 
64 /* packet structure */
65 typedef struct ipgpc_packet_s {
66 	/* IP Addresses are represented as IPV6 address structures */
67 	in6_addr_t saddr;	/* IP source address */
68 	in6_addr_t daddr;	/* IP destination address */
69 	uint16_t sport;		/* source port */
70 	uint16_t dport;		/* destination port */
71 	uint8_t proto;		/* protocol field */
72 	uint8_t dsfield;	/* Traffic class/DS */
73 	uid_t uid;		/* user id for packet */
74 	projid_t projid;	/* project id for packet */
75 	uint_t if_index;	/* interface index */
76 	uint32_t direction;	/* packet direction */
77 	char *if_groupname;	/* interface group name */
78 	uint_t if_groupname_len; /* interface group name length */
79 	uint_t len;		/* length of packet */
80 } ipgpc_packet_t;
81 
82 extern int ipgpc_debug;
83 extern boolean_t ipgpc_action_exist; /* if an ipgpc action exists */
84 
85 extern ipgpc_class_t *ipgpc_classify(int, ipgpc_packet_t *);
86 extern void parse_packet(ipgpc_packet_t *, mblk_t *);
87 extern void parse_packet6(ipgpc_packet_t *, mblk_t *);
88 extern void print_packet(int, ipgpc_packet_t *);
89 
90 #ifdef	__cplusplus
91 }
92 #endif
93 
94 #endif	/* _IPP_IPGPC_CLASSIFIER_H */
95