xref: /freebsd/sys/net/vnet.h (revision 13014ca04aad1931d41958b56f71a2c65b9a7a2c)
1 /*-
2  * Copyright (c) 2006-2008 University of Zagreb
3  * Copyright (c) 2006-2008 FreeBSD Foundation
4  *
5  * This software was developed by the University of Zagreb and the
6  * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
7  * FreeBSD Foundation.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD$
31  */
32 
33 #ifndef _NET_VNET_H_
34 #define _NET_VNET_H_
35 
36 #ifdef VIMAGE
37 #include "opt_route.h"
38 
39 #include <sys/proc.h>
40 #include <sys/protosw.h>
41 #include <sys/socket.h>
42 
43 #include <net/if.h>
44 #include <net/if_var.h>
45 #include <net/route.h>
46 #include <net/raw_cb.h>
47 
48 struct vnet_net {
49 	int	_if_index;
50 	struct	ifindex_entry *_ifindex_table;
51 	struct	ifnethead _ifnet;
52 	struct	ifgrouphead _ifg_head;
53 
54 	int	_if_indexlim;
55 	struct	knlist _ifklist;
56 
57 	struct	rtstat _rtstat;
58 	struct	radix_node_head *_rt_tables[RT_MAXFIBS][AF_MAX+1];
59 	int	_rttrash;
60 
61 	struct	ifnet *_loif;
62 	LIST_HEAD(, lo_softc) _lo_list;
63 
64 	LIST_HEAD(, rawcb) _rawcb_list;
65 
66 	int	_ether_ipfw;
67 };
68 
69 #endif
70 
71 /*
72  * Symbol translation macros
73  */
74 #define	INIT_VNET_NET(vnet) \
75 	INIT_FROM_VNET(vnet, VNET_MOD_NET, struct vnet_net, vnet_net)
76 
77 #define	VNET_NET(sym)	VSYM(vnet_net, sym)
78 
79 #define	V_ether_ipfw	VNET_NET(ether_ipfw)
80 #define	V_if_index	VNET_NET(if_index)
81 #define	V_if_indexlim	VNET_NET(if_indexlim)
82 #define	V_ifg_head	VNET_NET(ifg_head)
83 #define	V_ifindex_table	VNET_NET(ifindex_table)
84 #define	V_ifklist	VNET_NET(ifklist)
85 #define	V_ifnet		VNET_NET(ifnet)
86 #define	V_lo_list	VNET_NET(lo_list)
87 #define	V_loif		VNET_NET(loif)
88 #define	V_rawcb_list	VNET_NET(rawcb_list)
89 #define	V_rt_tables	VNET_NET(rt_tables)
90 #define	V_rtstat	VNET_NET(rtstat)
91 #define	V_rttrash	VNET_NET(rttrash)
92 
93 #endif /* !_NET_VNET_H_ */
94