xref: /illumos-gate/usr/src/uts/common/inet/ip6_asp.h (revision 2d6eb4a5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*f4b3ec61Sdh  * Common Development and Distribution License (the "License").
6*f4b3ec61Sdh  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*f4b3ec61Sdh  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_INET_IP6_ASP_H
277c478bd9Sstevel@tonic-gate #define	_INET_IP6_ASP_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <netinet/in.h>
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate #include <inet/ip6.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * The maximum size of the label, including NULL bytes following the
397c478bd9Sstevel@tonic-gate  * label string.  The implementation assumes that this value is 16.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate #define	IP6_ASP_MAXLABELSIZE	16
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate typedef struct ip6_asp {
447c478bd9Sstevel@tonic-gate 	in6_addr_t	ip6_asp_prefix;
457c478bd9Sstevel@tonic-gate 	in6_addr_t	ip6_asp_mask;
467c478bd9Sstevel@tonic-gate 	/*
477c478bd9Sstevel@tonic-gate 	 * ip6_asp_label must be on an 8 byte boundary because we cast
487c478bd9Sstevel@tonic-gate 	 * them as (int64_t *) in order to compare them as two 64 bit
497c478bd9Sstevel@tonic-gate 	 * integers rather than sixteen characters.
507c478bd9Sstevel@tonic-gate 	 */
517c478bd9Sstevel@tonic-gate 	union {
527c478bd9Sstevel@tonic-gate 		char	iau_label_c[IP6_ASP_MAXLABELSIZE];
537c478bd9Sstevel@tonic-gate 		int64_t	iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int64_t)];
547c478bd9Sstevel@tonic-gate 	} ip6_asp_u;
557c478bd9Sstevel@tonic-gate 	uint32_t	ip6_asp_precedence;
567c478bd9Sstevel@tonic-gate } ip6_asp_t;
577c478bd9Sstevel@tonic-gate #define	ip6_asp_label	ip6_asp_u.iau_label_c
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) && _LONG_LONG_ALIGNMENT_32 == 4
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * The ip6_asp structure as seen by a 64-bit kernel looking
637c478bd9Sstevel@tonic-gate  * at a 32-bit process, where the 32-bit process uses 32-bit
647c478bd9Sstevel@tonic-gate  * alignment for 64-bit quantities.  Like i386 does :-)
657c478bd9Sstevel@tonic-gate  */
667c478bd9Sstevel@tonic-gate typedef struct ip6_asp32 {
677c478bd9Sstevel@tonic-gate 	in6_addr_t	ip6_asp_prefix;
687c478bd9Sstevel@tonic-gate 	in6_addr_t	ip6_asp_mask;
697c478bd9Sstevel@tonic-gate 	union {
707c478bd9Sstevel@tonic-gate 		char	iau_label_c[IP6_ASP_MAXLABELSIZE];
717c478bd9Sstevel@tonic-gate 		int32_t	iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int32_t)];
727c478bd9Sstevel@tonic-gate 	} ip6_asp_u;
737c478bd9Sstevel@tonic-gate 	uint32_t	ip6_asp_precedence;
747c478bd9Sstevel@tonic-gate } ip6_asp32_t;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 && _LONG_LONG_ALIGNMENT_32 == 4 */
777c478bd9Sstevel@tonic-gate 
78*f4b3ec61Sdh #define	IP6_ASP_TABLE_REFHOLD(ipst) {			\
79*f4b3ec61Sdh 	ipst->ips_ip6_asp_refcnt++;			\
80*f4b3ec61Sdh 	ASSERT(ipst->ips_ip6_asp_refcnt != 0);		\
817c478bd9Sstevel@tonic-gate }
827c478bd9Sstevel@tonic-gate 
83*f4b3ec61Sdh #define	IP6_ASP_TABLE_REFRELE(ipst)	{		\
84*f4b3ec61Sdh 	mutex_enter(&ipst->ips_ip6_asp_lock);		\
85*f4b3ec61Sdh 	ASSERT(ipst->ips_ip6_asp_refcnt != 0);		\
86*f4b3ec61Sdh 	if (--ipst->ips_ip6_asp_refcnt == 0) {		\
87*f4b3ec61Sdh 		mutex_exit(&ipst->ips_ip6_asp_lock);	\
88*f4b3ec61Sdh 		ip6_asp_check_for_updates(ipst);		\
897c478bd9Sstevel@tonic-gate 	} else {					\
90*f4b3ec61Sdh 		mutex_exit(&ipst->ips_ip6_asp_lock);	\
917c478bd9Sstevel@tonic-gate 	}						\
927c478bd9Sstevel@tonic-gate }
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Structure used in the SIOCGDSTINFO request.
967c478bd9Sstevel@tonic-gate  * Used to retrieve information about the given destination
977c478bd9Sstevel@tonic-gate  * address, to be used by the caller to sort a list of
987c478bd9Sstevel@tonic-gate  * potential destination addresses.
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate struct dstinforeq {
1017c478bd9Sstevel@tonic-gate 	in6_addr_t	dir_daddr;		/* destination address */
1027c478bd9Sstevel@tonic-gate 	in6_addr_t	dir_saddr;		/* source address for daddr */
1037c478bd9Sstevel@tonic-gate 	in6addr_scope_t	dir_dscope;		/* destination scope */
1047c478bd9Sstevel@tonic-gate 	in6addr_scope_t	dir_sscope;		/* source scope */
1057c478bd9Sstevel@tonic-gate 	t_uscalar_t	dir_dmactype;		/* dl_mac_type of output inf */
1067c478bd9Sstevel@tonic-gate 	uint32_t	dir_precedence;		/* destination precedence */
1077c478bd9Sstevel@tonic-gate 	uint8_t		dir_dreachable : 1,	/* is destination reachable? */
1087c478bd9Sstevel@tonic-gate 			dir_sdeprecated : 1,	/* is source deprecated? */
1097c478bd9Sstevel@tonic-gate 			dir_labelmatch: 1,	/* src and dst labels match? */
1107c478bd9Sstevel@tonic-gate 			dir_padbits : 5;
1117c478bd9Sstevel@tonic-gate };
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate #ifdef _KERNEL
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate typedef void (*aspfunc_t)(ipsq_t *, queue_t *, mblk_t *, void *);
1167c478bd9Sstevel@tonic-gate 
117*f4b3ec61Sdh extern void	ip6_asp_free(ip_stack_t *);
118*f4b3ec61Sdh extern void	ip6_asp_init(ip_stack_t *);
119*f4b3ec61Sdh extern boolean_t	ip6_asp_can_lookup(ip_stack_t *);
120*f4b3ec61Sdh extern void	ip6_asp_table_refrele(ip_stack_t *);
121*f4b3ec61Sdh extern char	*ip6_asp_lookup(const in6_addr_t *, uint32_t *, ip_stack_t *);
122*f4b3ec61Sdh extern void	ip6_asp_replace(mblk_t *mp, ip6_asp_t *, size_t, boolean_t,
123*f4b3ec61Sdh     ip_stack_t *, model_t);
124*f4b3ec61Sdh extern int	ip6_asp_get(ip6_asp_t *, size_t, ip_stack_t *);
1257c478bd9Sstevel@tonic-gate extern boolean_t	ip6_asp_labelcmp(const char *, const char *);
1267c478bd9Sstevel@tonic-gate extern void	ip6_asp_pending_op(queue_t *, mblk_t *, aspfunc_t);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1317c478bd9Sstevel@tonic-gate }
1327c478bd9Sstevel@tonic-gate #endif
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate #endif	/* _INET_IP6_ASP_H */
135