Home | History | Annotate | Line # | Download | only in net
      1 /*	$OpenBSD: if.h,v 1.91 2007/06/25 16:37:58 henning Exp $	*/
      2 /*	$NetBSD: if_compat.h,v 1.2 2008/06/18 09:06:27 yamt Exp $	*/
      3 
      4 /*
      5  * Copyright (c) 1982, 1986, 1989, 1993
      6  *	The Regents of the University of California.  All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. Neither the name of the University nor the names of its contributors
     17  *    may be used to endorse or promote products derived from this software
     18  *    without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30  * SUCH DAMAGE.
     31  *
     32  *	@(#)if.h	8.1 (Berkeley) 6/10/93
     33  */
     34 
     35 #ifndef _NET_IF_COMPAT_H_
     36 #define _NET_IF_COMPAT_H_
     37 
     38 #include <sys/queue.h>
     39 
     40 /*
     41  * interface groups
     42  */
     43 
     44 #define	IFG_ALL		"all"		/* group contains all interfaces */
     45 #define	IFG_EGRESS	"egress"	/* if(s) default route(s) point to */
     46 
     47 struct ifg_group {
     48 	char				 ifg_group[IFNAMSIZ];
     49 	u_int				 ifg_refcnt;
     50 	void				*ifg_pf_kif;
     51 	int				 ifg_carp_demoted;
     52 	TAILQ_HEAD(, ifg_member)	 ifg_members;
     53 	TAILQ_ENTRY(ifg_group)		 ifg_next;
     54 };
     55 
     56 struct ifg_member {
     57 	TAILQ_ENTRY(ifg_member)	 ifgm_next;
     58 	struct ifnet		*ifgm_ifp;
     59 };
     60 
     61 struct ifg_list {
     62 	struct ifg_group	*ifgl_group;
     63 	TAILQ_ENTRY(ifg_list)	 ifgl_next;
     64 };
     65 
     66 TAILQ_HEAD(ifg_list_head, ifg_list);
     67 
     68 struct ifg_req {
     69 	union {
     70 		char			 ifgrqu_group[IFNAMSIZ];
     71 		char			 ifgrqu_member[IFNAMSIZ];
     72 	} ifgrq_ifgrqu;
     73 #define	ifgrq_group	ifgrq_ifgrqu.ifgrqu_group
     74 #define	ifgrq_member	ifgrq_ifgrqu.ifgrqu_member
     75 };
     76 
     77 struct ifg_attrib {
     78 	int	ifg_carp_demoted;
     79 };
     80 
     81 /*
     82  * Used to lookup groups for an interface
     83  */
     84 struct ifgroupreq {
     85 	char	ifgr_name[IFNAMSIZ];
     86 	u_int	ifgr_len;
     87 	union {
     88 		char			 ifgru_group[IFNAMSIZ];
     89 		struct	ifg_req		*ifgru_groups;
     90 		struct	ifg_attrib	 ifgru_attrib;
     91 	} ifgr_ifgru;
     92 #define ifgr_group	ifgr_ifgru.ifgru_group
     93 #define ifgr_groups	ifgr_ifgru.ifgru_groups
     94 #define ifgr_attrib	ifgr_ifgru.ifgru_attrib
     95 };
     96 
     97 #ifdef _KERNEL
     98 void	if_init_groups(struct ifnet *);
     99 void	if_destroy_groups(struct ifnet *);
    100 struct	ifg_list_head *if_get_groups(struct ifnet *);
    101 
    102 struct	ifg_group *if_creategroup(const char *);
    103 int	if_addgroup(struct ifnet *, const char *);
    104 int	if_delgroup(struct ifnet *, const char *);
    105 void	if_group_routechange(struct sockaddr *, struct sockaddr *);
    106 #endif /* _KERNEL */
    107 
    108 #endif /* !_NET_IF_COMPAT_H_ */
    109