xref: /titanic_44/usr/src/uts/common/inet/ip6_asp.h (revision 47b4653e9ff2a8aebb64f9e357713fd04108674b)
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_IP6_ASP_H
27 #define	_INET_IP6_ASP_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <netinet/in.h>
36 #include <sys/types.h>
37 #include <inet/ip6.h>
38 
39 /*
40  * The maximum size of the label, including NULL bytes following the
41  * label string.  The implementation assumes that this value is 16.
42  */
43 #define	IP6_ASP_MAXLABELSIZE	16
44 
45 typedef struct ip6_asp {
46 	in6_addr_t	ip6_asp_prefix;
47 	in6_addr_t	ip6_asp_mask;
48 	/*
49 	 * ip6_asp_label must be on an 8 byte boundary because we cast
50 	 * them as (int64_t *) in order to compare them as two 64 bit
51 	 * integers rather than sixteen characters.
52 	 */
53 	union {
54 		char	iau_label_c[IP6_ASP_MAXLABELSIZE];
55 		int64_t	iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int64_t)];
56 	} ip6_asp_u;
57 	uint32_t	ip6_asp_precedence;
58 } ip6_asp_t;
59 #define	ip6_asp_label	ip6_asp_u.iau_label_c
60 
61 #if defined(_SYSCALL32) && _LONG_LONG_ALIGNMENT_32 == 4
62 
63 /*
64  * The ip6_asp structure as seen by a 64-bit kernel looking
65  * at a 32-bit process, where the 32-bit process uses 32-bit
66  * alignment for 64-bit quantities.  Like i386 does :-)
67  */
68 typedef struct ip6_asp32 {
69 	in6_addr_t	ip6_asp_prefix;
70 	in6_addr_t	ip6_asp_mask;
71 	union {
72 		char	iau_label_c[IP6_ASP_MAXLABELSIZE];
73 		int32_t	iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int32_t)];
74 	} ip6_asp_u;
75 	uint32_t	ip6_asp_precedence;
76 } ip6_asp32_t;
77 
78 #endif	/* _SYSCALL32 && _LONG_LONG_ALIGNMENT_32 == 4 */
79 
80 #define	IP6_ASP_TABLE_REFHOLD(ipst) {			\
81 	ipst->ips_ip6_asp_refcnt++;			\
82 	ASSERT(ipst->ips_ip6_asp_refcnt != 0);		\
83 }
84 
85 #define	IP6_ASP_TABLE_REFRELE(ipst)	{		\
86 	mutex_enter(&ipst->ips_ip6_asp_lock);		\
87 	ASSERT(ipst->ips_ip6_asp_refcnt != 0);		\
88 	if (--ipst->ips_ip6_asp_refcnt == 0) {		\
89 		mutex_exit(&ipst->ips_ip6_asp_lock);	\
90 		ip6_asp_check_for_updates(ipst);		\
91 	} else {					\
92 		mutex_exit(&ipst->ips_ip6_asp_lock);	\
93 	}						\
94 }
95 
96 /*
97  * Structure used in the SIOCGDSTINFO request.
98  * Used to retrieve information about the given destination
99  * address, to be used by the caller to sort a list of
100  * potential destination addresses.
101  */
102 struct dstinforeq {
103 	in6_addr_t	dir_daddr;		/* destination address */
104 	in6_addr_t	dir_saddr;		/* source address for daddr */
105 	in6addr_scope_t	dir_dscope;		/* destination scope */
106 	in6addr_scope_t	dir_sscope;		/* source scope */
107 	t_uscalar_t	dir_dmactype;		/* dl_mac_type of output inf */
108 	uint32_t	dir_precedence;		/* destination precedence */
109 	uint8_t		dir_dreachable : 1,	/* is destination reachable? */
110 			dir_sdeprecated : 1,	/* is source deprecated? */
111 			dir_labelmatch: 1,	/* src and dst labels match? */
112 			dir_padbits : 5;
113 };
114 
115 #ifdef _KERNEL
116 
117 typedef void (*aspfunc_t)(ipsq_t *, queue_t *, mblk_t *, void *);
118 
119 extern void	ip6_asp_free(ip_stack_t *);
120 extern void	ip6_asp_init(ip_stack_t *);
121 extern boolean_t	ip6_asp_can_lookup(ip_stack_t *);
122 extern void	ip6_asp_table_refrele(ip_stack_t *);
123 extern char	*ip6_asp_lookup(const in6_addr_t *, uint32_t *, ip_stack_t *);
124 extern void	ip6_asp_replace(mblk_t *mp, ip6_asp_t *, size_t, boolean_t,
125     ip_stack_t *, model_t);
126 extern int	ip6_asp_get(ip6_asp_t *, size_t, ip_stack_t *);
127 extern boolean_t	ip6_asp_labelcmp(const char *, const char *);
128 extern void	ip6_asp_pending_op(queue_t *, mblk_t *, aspfunc_t);
129 
130 #endif /* _KERNEL */
131 
132 #ifdef	__cplusplus
133 }
134 #endif
135 
136 #endif	/* _INET_IP6_ASP_H */
137