xref: /titanic_51/usr/src/uts/common/inet/ipp_common.h (revision 15d9d0b528387242011cdcc6190c9e598cfe3a07)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_INET_IPP_COMMON_H
27 #define	_INET_IPP_COMMON_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #ifdef _KERNEL
36 #include <ipp/ipp.h>
37 
38 /*
39  * IPP  -- IP Policy -- interface.
40  *
41  * WARNING: Everything in this file is private, belonging to the IPP
42  * subsystem.  The interfaces and declarations made here are subject
43  * to change.
44  */
45 
46 extern uint32_t ipp_action_count;
47 
48 /* Whether ip policy is enabled at callout position proc */
49 #define	IPP_ENABLED(proc, ipst)	((ipp_action_count != 0) && \
50 	(~((ipst)->ips_ip_policy_mask) & (proc)))
51 
52 /* Apply IPQoS policies for inbound traffic? */
53 #define	IP6_IN_IPP(flags, ipst) (IPP_ENABLED(IPP_LOCAL_IN, ipst) &&	\
54 	(!((flags) & IP6_NO_IPPOLICY)))
55 
56 /* Apply IPQoS policies for oubound traffic? */
57 #define	IP6_OUT_IPP(flags, ipst)	\
58 	(IPP_ENABLED(IPP_LOCAL_OUT, ipst) && (!((flags) & IP6_NO_IPPOLICY)))
59 
60 /* Extracts 8 bit traffic class from IPV6 flow label field */
61 #ifdef  _BIG_ENDIAN
62 #define	__IPV6_TCLASS_FROM_FLOW(n)	(((n)>>20) & 0xff)
63 #else
64 #define	__IPV6_TCLASS_FROM_FLOW(n)	((((n)<<4) | (((n)>>12) & 0xf)) & 0xff)
65 #endif /* _BIG_ENDIAN */
66 
67 typedef	enum {
68 	IPP_LOCAL_IN =	0x01,
69 	IPP_LOCAL_OUT =	0x02,
70 	IPP_FWD_IN =	0x04,
71 	IPP_FWD_OUT =	0x08
72 } ip_proc_t;
73 
74 /* IP private data structure */
75 typedef	struct ip_priv {
76 	ip_proc_t	proc;
77 	uint32_t	ill_index;
78 } ip_priv_t;
79 
80 /* The entry point for ip policy processing */
81 extern void ip_process(ip_proc_t, mblk_t **, uint32_t);
82 extern void ip_priv_free(void *);
83 #endif /* _KERNEL */
84 
85 
86 #ifdef	__cplusplus
87 }
88 #endif
89 
90 #endif	/* _INET_IPP_COMMON_H */
91