xref: /titanic_44/usr/src/uts/common/ipp/ipgpc/classifier.h (revision bde3d612a7c090234c60e6e4578821237a5db135)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _IPP_IPGPC_CLASSIFIER_H
27 #define	_IPP_IPGPC_CLASSIFIER_H
28 
29 #include <sys/types.h>
30 #include <sys/cmn_err.h>
31 #include <ipp/ipgpc/filters.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /* Header file for classifier implementation for ipgpc */
38 
39 #define	IPGPC_DEBUG
40 
41 #ifdef IPGPC_DEBUG
42 #include <sys/debug.h>
43 
44 #define	ipgpc0dbg(a)	printf a
45 #define	ipgpc1dbg(a)	if (ipgpc_debug > 2) printf a
46 #define	ipgpc2dbg(a)	if (ipgpc_debug > 3) printf a
47 #define	ipgpc3dbg(a)	if (ipgpc_debug > 4) printf a
48 #define	ipgpc4dbg(a)	if (ipgpc_debug > 5) printf a
49 #else
50 #define	ipgpc0dbg(a)		/*  */
51 #define	ipgpc1dbg(a)		/*  */
52 #define	ipgpc2dbg(a)		/*  */
53 #define	ipgpc3dbg(a)		/*  */
54 #define	ipgpc4dbg(a)		/*  */
55 #endif /* IPGPC_DEBUG */
56 
57 #define	BUMP_STATS(x)		++(x)
58 #define	SET_STATS(x, y)		x = y
59 #define	UPDATE_STATS(x, y)	x += y
60 
61 /* packet structure */
62 typedef struct ipgpc_packet_s {
63 	/* IP Addresses are represented as IPV6 address structures */
64 	in6_addr_t saddr;	/* IP source address */
65 	in6_addr_t daddr;	/* IP destination address */
66 	uint16_t sport;		/* source port */
67 	uint16_t dport;		/* destination port */
68 	uint8_t proto;		/* protocol field */
69 	uint8_t dsfield;	/* Traffic class/DS */
70 	uid_t uid;		/* user id for packet */
71 	projid_t projid;	/* project id for packet */
72 	uint_t if_index;	/* interface index */
73 	uint32_t direction;	/* packet direction */
74 	uint_t len;		/* length of packet */
75 } ipgpc_packet_t;
76 
77 extern int ipgpc_debug;
78 extern boolean_t ipgpc_action_exist; /* if an ipgpc action exists */
79 
80 extern ipgpc_class_t *ipgpc_classify(int, ipgpc_packet_t *);
81 extern void parse_packet(ipgpc_packet_t *, mblk_t *);
82 extern void parse_packet6(ipgpc_packet_t *, mblk_t *);
83 extern void print_packet(int, ipgpc_packet_t *);
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _IPP_IPGPC_CLASSIFIER_H */
90