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