Home | History | Annotate | Download | only in sctp
      1      0    stevel /*
      2      0    stevel  * CDDL HEADER START
      3      0    stevel  *
      4      0    stevel  * The contents of this file are subject to the terms of the
      5   3448  dh155122  * Common Development and Distribution License (the "License").
      6   3448  dh155122  * You may not use this file except in compliance with the License.
      7      0    stevel  *
      8      0    stevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9      0    stevel  * or http://www.opensolaris.org/os/licensing.
     10      0    stevel  * See the License for the specific language governing permissions
     11      0    stevel  * and limitations under the License.
     12      0    stevel  *
     13      0    stevel  * When distributing Covered Code, include this CDDL HEADER in each
     14      0    stevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15      0    stevel  * If applicable, add the following below this CDDL HEADER, with the
     16      0    stevel  * fields enclosed by brackets "[]" replaced with your own identifying
     17      0    stevel  * information: Portions Copyright [yyyy] [name of copyright owner]
     18      0    stevel  *
     19      0    stevel  * CDDL HEADER END
     20      0    stevel  */
     21      0    stevel /*
     22  11042      Erik  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23      0    stevel  * Use is subject to license terms.
     24      0    stevel  */
     25      0    stevel 
     26      0    stevel #ifndef	_SCTP_ADDR_H
     27      0    stevel #define	_SCTP_ADDR_H
     28      0    stevel 
     29      0    stevel #include <sys/list.h>
     30      0    stevel #include <sys/zone.h>
     31      0    stevel #include <inet/ip.h>
     32      0    stevel 
     33      0    stevel #ifdef	__cplusplus
     34      0    stevel extern "C" {
     35      0    stevel #endif
     36      0    stevel 
     37      0    stevel /*
     38      0    stevel  * SCTP IPIF structure - only relevant fields from ipif_t retained
     39      0    stevel  *
     40      0    stevel  * There is a global array, sctp_g_ipifs, to store all addresses of
     41      0    stevel  * the system.  Each element of the global array is a list of
     42      0    stevel  * sctp_ipif_t.
     43      0    stevel  *
     44      0    stevel  * This structure is also shared by all SCTP PCBs.  Each SCTP PCB has
     45      0    stevel  * an array of source addresses.  Each element of that array is a list
     46      0    stevel  * of sctp_saddr_ipif_t.  And each sctp_saddr_ipif_t has a pointer
     47      0    stevel  * to a sctp_ipif_t.  The reason for sctp_saddr_ipif_t is that each
     48      0    stevel  * SCTP PCB may do different things to a source address.  This info
     49      0    stevel  * is stored locally in sctp_saddr_ipif_t.
     50      0    stevel  *
     51      0    stevel  */
     52      0    stevel typedef struct sctp_ipif_s {
     53      0    stevel 	list_node_t		sctp_ipifs;	/* Used by the global list */
     54      0    stevel 	struct sctp_ill_s	*sctp_ipif_ill;
     55      0    stevel 	uint_t			sctp_ipif_id;
     56      0    stevel 	in6_addr_t		sctp_ipif_saddr;
     57      0    stevel 	int			sctp_ipif_state;
     58      0    stevel 	uint32_t		sctp_ipif_refcnt;
     59      0    stevel 	zoneid_t		sctp_ipif_zoneid;
     60      0    stevel 	krwlock_t		sctp_ipif_lock;
     61      0    stevel 	boolean_t		sctp_ipif_isv6;
     62    432  vi117747 	uint64_t		sctp_ipif_flags;
     63      0    stevel } sctp_ipif_t;
     64      0    stevel 
     65      0    stevel /* ipif_state */
     66      0    stevel #define	SCTP_IPIFS_CONDEMNED	-1
     67      0    stevel #define	SCTP_IPIFS_INVALID	-2
     68      0    stevel #define	SCTP_IPIFS_DOWN		1
     69      0    stevel #define	SCTP_IPIFS_UP		2
     70      0    stevel 
     71    252  vi117747 /*
     72    252  vi117747  * Individual SCTP source address structure.
     73    252  vi117747  * saddr_ipifp is the actual pointer to the ipif/address.
     74    252  vi117747  * saddr_ipif_dontsrc is used to mark an address as currently unusable. This
     75    252  vi117747  * would be the case when we have added/deleted an address using sctp_bindx()
     76    252  vi117747  * and are waiting for the ASCONF ACK from the peer to confirm the addition/
     77    252  vi117747  * deletion. Additionally, saddr_ipif_delete_pending is used to specifically
     78    252  vi117747  * indicate that an address delete operation is in progress.
     79    252  vi117747  */
     80      0    stevel typedef struct sctp_saddrs_ipif_s {
     81      0    stevel 	list_node_t	saddr_ipif;
     82      0    stevel 	sctp_ipif_t 	*saddr_ipifp;
     83      0    stevel 	uint32_t	saddr_ipif_dontsrc : 1,
     84      0    stevel 			saddr_ipif_delete_pending : 1,
     85    432  vi117747 			saddr_ipif_unconfirmed : 1,
     86    432  vi117747 			pad : 29;
     87      0    stevel } sctp_saddr_ipif_t;
     88    432  vi117747 
     89    432  vi117747 #define	SCTP_DONT_SRC(sctp_saddr)	\
     90    432  vi117747 	((sctp_saddr)->saddr_ipif_dontsrc ||	\
     91    432  vi117747 	(sctp_saddr)->saddr_ipif_unconfirmed)
     92    432  vi117747 
     93      0    stevel 
     94    252  vi117747 /*
     95    252  vi117747  * SCTP ILL structure - only relevant fields from ill_t retained.
     96    252  vi117747  * This pretty much reflects the ILL<->IPIF relation that IP maintains.
     97    252  vi117747  * At present the only state an ILL can be in is CONDEMNED or not.
     98    252  vi117747  * sctp_ill_ipifcnt gives the number of IPIFs for this ILL,
     99    252  vi117747  * sctp_ill_index is phyint_ifindex in the actual ILL structure (in IP)
    100    252  vi117747  * and sctp_ill_flags is ill_flags from the ILL structure.
    101   3448  dh155122  *
    102   3448  dh155122  * The comment below (and for other netstack_t references) refers
    103   3448  dh155122  * to the fact that we only do netstack_hold in particular cases,
    104   3448  dh155122  * such as the references from open streams (ill_t and conn_t's
    105   3448  dh155122  * pointers). Internally within IP we rely on IP's ability to cleanup e.g.
    106   3448  dh155122  * ire_t's when an ill goes away.
    107    252  vi117747  */
    108      0    stevel typedef struct sctp_ill_s {
    109   3448  dh155122 	list_node_t	sctp_ills;
    110   3448  dh155122 	int		sctp_ill_name_length;
    111   3448  dh155122 	char		*sctp_ill_name;
    112   3448  dh155122 	int		sctp_ill_state;
    113   3448  dh155122 	uint32_t	sctp_ill_ipifcnt;
    114   3448  dh155122 	uint_t		sctp_ill_index;
    115   3448  dh155122 	uint64_t	sctp_ill_flags;
    116   4311  vi117747 	boolean_t	sctp_ill_isv6;
    117   3448  dh155122 	netstack_t	*sctp_ill_netstack; /* Does not have a netstack_hold */
    118      0    stevel } sctp_ill_t;
    119      0    stevel 
    120      0    stevel /* ill_state */
    121      0    stevel #define	SCTP_ILLS_CONDEMNED	-1
    122      0    stevel 
    123      0    stevel #define	SCTP_ILL_HASH	16
    124      0    stevel 
    125      0    stevel typedef struct sctp_ill_hash_s {
    126      0    stevel 	list_t	sctp_ill_list;
    127      0    stevel 	int	ill_count;
    128      0    stevel } sctp_ill_hash_t;
    129      0    stevel 
    130      0    stevel 
    131      0    stevel #define	SCTP_IPIF_REFHOLD(sctp_ipif) {				\
    132      0    stevel 	atomic_add_32(&(sctp_ipif)->sctp_ipif_refcnt, 1);	\
    133      0    stevel }
    134      0    stevel 
    135      0    stevel #define	SCTP_IPIF_REFRELE(sctp_ipif) {					\
    136   3510  vi117747 	rw_enter(&(sctp_ipif)->sctp_ipif_lock, RW_WRITER);		\
    137      0    stevel 	ASSERT((sctp_ipif)->sctp_ipif_refcnt != 0);			\
    138   3510  vi117747 	if (--(sctp_ipif)->sctp_ipif_refcnt == 0 && 			\
    139   3510  vi117747 	    (sctp_ipif)->sctp_ipif_state == SCTP_IPIFS_CONDEMNED) {	\
    140   3510  vi117747 		rw_exit(&(sctp_ipif)->sctp_ipif_lock);			\
    141      0    stevel 		sctp_ipif_inactive(sctp_ipif);				\
    142   3510  vi117747 	} else {							\
    143   3510  vi117747 		rw_exit(&(sctp_ipif)->sctp_ipif_lock);			\
    144   3510  vi117747 	}								\
    145      0    stevel }
    146      0    stevel 
    147      0    stevel /* Address set comparison results. */
    148      0    stevel #define	SCTP_ADDR_EQUAL		1
    149      0    stevel #define	SCTP_ADDR_SUBSET	2
    150      0    stevel #define	SCTP_ADDR_OVERLAP	3
    151      0    stevel #define	SCTP_ADDR_DISJOINT	4
    152      0    stevel 
    153    852  vi117747 extern int		sctp_valid_addr_list(sctp_t *, const void *, uint32_t,
    154    852  vi117747 			    uchar_t *, size_t);
    155      0    stevel extern int		sctp_dup_saddrs(sctp_t *, sctp_t *, int);
    156      0    stevel extern int		sctp_compare_saddrs(sctp_t *, sctp_t *);
    157    852  vi117747 extern sctp_saddr_ipif_t	*sctp_saddr_lookup(sctp_t *, in6_addr_t *,
    158    852  vi117747 				    uint_t);
    159   4818    kcpoon extern in6_addr_t	sctp_get_valid_addr(sctp_t *, boolean_t, boolean_t *);
    160    432  vi117747 extern size_t		sctp_saddr_info(sctp_t *, int, uchar_t *, boolean_t);
    161      0    stevel extern void		sctp_del_saddr_list(sctp_t *, const void *, int,
    162      0    stevel 			    boolean_t);
    163      0    stevel extern void		sctp_del_saddr(sctp_t *, sctp_saddr_ipif_t *);
    164      0    stevel extern void		sctp_free_saddrs(sctp_t *);
    165   3448  dh155122 extern void		sctp_saddr_init(sctp_stack_t *);
    166   3448  dh155122 extern void		sctp_saddr_fini(sctp_stack_t *);
    167      0    stevel extern int		sctp_getmyaddrs(void *, void *, int *);
    168    852  vi117747 extern int		sctp_saddr_add_addr(sctp_t *, in6_addr_t *, uint_t);
    169   4818    kcpoon extern void		sctp_check_saddr(sctp_t *, int, boolean_t,
    170   4818    kcpoon 			    in6_addr_t *);
    171      0    stevel 
    172      0    stevel #ifdef	__cplusplus
    173      0    stevel }
    174      0    stevel #endif
    175      0    stevel 
    176      0    stevel #endif	/* _SCTP_ADDR_H */
    177