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