xref: /illumos-gate/usr/src/uts/common/inet/ip_listutils.h (revision 45ede40b2394db7967e59f19288fae9b62efd4aa)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_INET_IP_LISTUTILS_H
28 #define	_INET_IP_LISTUTILS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef	_KERNEL
37 
38 boolean_t	lists_are_different(const slist_t *, const slist_t *);
39 boolean_t	list_has_addr(const slist_t *, const in6_addr_t *);
40 void		l_intersection(const slist_t *, const slist_t *, slist_t *);
41 void		l_difference(const slist_t *, const slist_t *, slist_t *);
42 void		l_remove(slist_t *, const in6_addr_t *);
43 slist_t		*l_alloc_copy(const slist_t *);
44 void		l_copy(const slist_t *, slist_t *);
45 void		l_union_in_a(slist_t *, const slist_t *, boolean_t *);
46 void		l_intersection_in_a(slist_t *, const slist_t *);
47 void		l_difference_in_a(slist_t *, const slist_t *);
48 slist_t		*l_alloc();
49 void		l_free(slist_t *);
50 
51 #define	SLIST_IS_EMPTY(sl)	(((sl) == NULL) || ((sl)->sl_numsrc == 0))
52 #define	SLIST_CNT(sl)		(((sl) == NULL) ? 0 : ((sl)->sl_numsrc))
53 #define	CLEAR_SLIST(sl)		if ((sl) != NULL) (sl)->sl_numsrc = 0
54 #define	FREE_SLIST(sl)		if ((sl) != NULL) l_free((sl))
55 #define	COPY_SLIST(sl, newsl)			\
56 	if ((newsl) == NULL)			\
57 		(newsl) = l_alloc_copy((sl));	\
58 	else					\
59 		l_copy((sl), (newsl))
60 
61 #endif	/* _KERNEL */
62 
63 #ifdef	__cplusplus
64 }
65 #endif
66 
67 #endif	/* _INET_IP_LISTUTILS_H */
68