xref: /onnv-gate/usr/src/uts/common/inet/sctp/sctp_addr.h (revision 252:8fc692a5cbf7)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*252Svi117747  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SCTP_ADDR_H
280Sstevel@tonic-gate #define	_SCTP_ADDR_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/list.h>
330Sstevel@tonic-gate #include <sys/zone.h>
340Sstevel@tonic-gate #include <inet/ip.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * SCTP IPIF structure - only relevant fields from ipif_t retained
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  * There is a global array, sctp_g_ipifs, to store all addresses of
440Sstevel@tonic-gate  * the system.  Each element of the global array is a list of
450Sstevel@tonic-gate  * sctp_ipif_t.
460Sstevel@tonic-gate  *
470Sstevel@tonic-gate  * This structure is also shared by all SCTP PCBs.  Each SCTP PCB has
480Sstevel@tonic-gate  * an array of source addresses.  Each element of that array is a list
490Sstevel@tonic-gate  * of sctp_saddr_ipif_t.  And each sctp_saddr_ipif_t has a pointer
500Sstevel@tonic-gate  * to a sctp_ipif_t.  The reason for sctp_saddr_ipif_t is that each
510Sstevel@tonic-gate  * SCTP PCB may do different things to a source address.  This info
520Sstevel@tonic-gate  * is stored locally in sctp_saddr_ipif_t.
530Sstevel@tonic-gate  *
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate typedef struct sctp_ipif_s {
560Sstevel@tonic-gate 	list_node_t		sctp_ipifs;	/* Used by the global list */
570Sstevel@tonic-gate 	struct sctp_ill_s	*sctp_ipif_ill;
580Sstevel@tonic-gate 	uint_t			sctp_ipif_mtu;
590Sstevel@tonic-gate 	uint_t			sctp_ipif_id;
600Sstevel@tonic-gate 	in6_addr_t		sctp_ipif_saddr;
610Sstevel@tonic-gate 	int			sctp_ipif_state;
620Sstevel@tonic-gate 	uint32_t		sctp_ipif_refcnt;
630Sstevel@tonic-gate 	zoneid_t		sctp_ipif_zoneid;
640Sstevel@tonic-gate 	krwlock_t		sctp_ipif_lock;
650Sstevel@tonic-gate 	boolean_t		sctp_ipif_isv6;
660Sstevel@tonic-gate } sctp_ipif_t;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate /* ipif_state */
690Sstevel@tonic-gate #define	SCTP_IPIFS_CONDEMNED	-1
700Sstevel@tonic-gate #define	SCTP_IPIFS_INVALID	-2
710Sstevel@tonic-gate #define	SCTP_IPIFS_DOWN		1
720Sstevel@tonic-gate #define	SCTP_IPIFS_UP		2
730Sstevel@tonic-gate 
74*252Svi117747 /*
75*252Svi117747  * Individual SCTP source address structure.
76*252Svi117747  * saddr_ipifp is the actual pointer to the ipif/address.
77*252Svi117747  * saddr_ipif_dontsrc is used to mark an address as currently unusable. This
78*252Svi117747  * would be the case when we have added/deleted an address using sctp_bindx()
79*252Svi117747  * and are waiting for the ASCONF ACK from the peer to confirm the addition/
80*252Svi117747  * deletion. Additionally, saddr_ipif_delete_pending is used to specifically
81*252Svi117747  * indicate that an address delete operation is in progress.
82*252Svi117747  */
830Sstevel@tonic-gate typedef struct sctp_saddrs_ipif_s {
840Sstevel@tonic-gate 	list_node_t	saddr_ipif;
850Sstevel@tonic-gate 	sctp_ipif_t 	*saddr_ipifp;
860Sstevel@tonic-gate 	uint32_t	saddr_ipif_dontsrc : 1,
870Sstevel@tonic-gate 			saddr_ipif_delete_pending : 1,
880Sstevel@tonic-gate 			pad : 30;
890Sstevel@tonic-gate } sctp_saddr_ipif_t;
900Sstevel@tonic-gate 
91*252Svi117747 /*
92*252Svi117747  * SCTP ILL structure - only relevant fields from ill_t retained.
93*252Svi117747  * This pretty much reflects the ILL<->IPIF relation that IP maintains.
94*252Svi117747  * At present the only state an ILL can be in is CONDEMNED or not.
95*252Svi117747  * sctp_ill_ipifcnt gives the number of IPIFs for this ILL,
96*252Svi117747  * sctp_ill_index is phyint_ifindex in the actual ILL structure (in IP)
97*252Svi117747  * and sctp_ill_flags is ill_flags from the ILL structure.
98*252Svi117747  */
990Sstevel@tonic-gate typedef struct sctp_ill_s {
1000Sstevel@tonic-gate 	list_node_t		sctp_ills;
1010Sstevel@tonic-gate 	int			sctp_ill_name_length;
1020Sstevel@tonic-gate 	char			*sctp_ill_name;
1030Sstevel@tonic-gate 	int			sctp_ill_state;
1040Sstevel@tonic-gate 	uint32_t		sctp_ill_ipifcnt;
1050Sstevel@tonic-gate 	uint_t			sctp_ill_index;
1060Sstevel@tonic-gate 	uint64_t		sctp_ill_flags;
1070Sstevel@tonic-gate } sctp_ill_t;
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate /* ill_state */
1100Sstevel@tonic-gate #define	SCTP_ILLS_CONDEMNED	-1
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate #define	SCTP_ILL_HASH	16
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate typedef struct sctp_ill_hash_s {
1150Sstevel@tonic-gate 	list_t	sctp_ill_list;
1160Sstevel@tonic-gate 	int	ill_count;
1170Sstevel@tonic-gate } sctp_ill_hash_t;
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate /* Global list of SCTP ILLs */
1200Sstevel@tonic-gate extern sctp_ill_hash_t	sctp_g_ills[SCTP_ILL_HASH];
1210Sstevel@tonic-gate krwlock_t		sctp_g_ills_lock;
1220Sstevel@tonic-gate extern uint32_t		sctp_ills_count;
1230Sstevel@tonic-gate extern uint32_t		sctp_ills_min_mtu;
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate /* Global list of SCTP ipifs */
1260Sstevel@tonic-gate extern	sctp_ipif_hash_t	sctp_g_ipifs[SCTP_IPIF_HASH];
1270Sstevel@tonic-gate extern	uint32_t		sctp_g_ipifs_count;
1280Sstevel@tonic-gate krwlock_t			sctp_g_ipifs_lock;
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate #define	SCTP_IPIF_REFHOLD(sctp_ipif) {				\
1320Sstevel@tonic-gate 	atomic_add_32(&(sctp_ipif)->sctp_ipif_refcnt, 1);	\
1330Sstevel@tonic-gate 	ASSERT((sctp_ipif)->sctp_ipif_refcnt != 0);		\
1340Sstevel@tonic-gate }
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate #define	SCTP_IPIF_REFRELE(sctp_ipif) {					\
1370Sstevel@tonic-gate 	ASSERT((sctp_ipif)->sctp_ipif_refcnt != 0);			\
1380Sstevel@tonic-gate 	if (atomic_add_32_nv(&(sctp_ipif)->sctp_ipif_refcnt, -1) == 0)	\
1390Sstevel@tonic-gate 		sctp_ipif_inactive(sctp_ipif);				\
1400Sstevel@tonic-gate }
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate /* Address set comparison results. */
1430Sstevel@tonic-gate #define	SCTP_ADDR_EQUAL		1
1440Sstevel@tonic-gate #define	SCTP_ADDR_SUBSET	2
1450Sstevel@tonic-gate #define	SCTP_ADDR_OVERLAP	3
1460Sstevel@tonic-gate #define	SCTP_ADDR_DISJOINT	4
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate extern void		sctp_update_ill(ill_t *, int);
1490Sstevel@tonic-gate extern void		sctp_update_ipif(ipif_t *, int);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate extern int		sctp_valid_addr_list(sctp_t *, const void *, uint32_t);
1520Sstevel@tonic-gate extern int		sctp_dup_saddrs(sctp_t *, sctp_t *, int);
1530Sstevel@tonic-gate extern int		sctp_compare_saddrs(sctp_t *, sctp_t *);
1540Sstevel@tonic-gate extern sctp_saddr_ipif_t	*sctp_saddr_lookup(sctp_t *, in6_addr_t *);
1550Sstevel@tonic-gate extern in6_addr_t	sctp_get_valid_addr(sctp_t *, boolean_t isv6);
156*252Svi117747 extern size_t		sctp_saddr_info(sctp_t *, int, uchar_t *);
1570Sstevel@tonic-gate extern void		sctp_del_saddr_list(sctp_t *, const void *, int,
1580Sstevel@tonic-gate 			    boolean_t);
1590Sstevel@tonic-gate extern void		sctp_del_saddr(sctp_t *, sctp_saddr_ipif_t *);
1600Sstevel@tonic-gate extern void		sctp_free_saddrs(sctp_t *);
1610Sstevel@tonic-gate extern void		sctp_saddr_init();
1620Sstevel@tonic-gate extern void		sctp_saddr_fini();
1630Sstevel@tonic-gate extern sctp_saddr_ipif_t	*sctp_ipif_lookup(sctp_t *, uint_t);
1640Sstevel@tonic-gate extern int		sctp_getmyaddrs(void *, void *, int *);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate #ifdef	__cplusplus
1670Sstevel@tonic-gate }
1680Sstevel@tonic-gate #endif
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate #endif	/* _SCTP_ADDR_H */
171