]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/conf.h
Add VLAN support in config
[mirror_lxc.git] / src / lxc / conf.h
1 /*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2008
5 *
6 * Authors:
7 * Daniel Lezcano <dlezcano at fr.ibm.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23 #ifndef _conf_h
24 #define _conf_h
25
26 #include <netinet/in.h>
27 #include <sys/param.h>
28
29 #include <lxc/list.h>
30
31 enum {
32 EMPTY,
33 VETH,
34 MACVLAN,
35 PHYS,
36 VLAN,
37 MAXCONFTYPE,
38 };
39
40 /*
41 * Defines the structure to configure an ipv4 address
42 * @address : ipv4 address
43 * @broadcast : ipv4 broadcast address
44 * @mask : network mask
45 */
46 struct lxc_inetdev {
47 struct in_addr addr;
48 struct in_addr bcast;
49 int prefix;
50 };
51
52 struct lxc_route {
53 struct in_addr addr;
54 };
55
56 /*
57 * Defines the structure to configure an ipv6 address
58 * @flags : set the address up
59 * @address : ipv6 address
60 * @broadcast : ipv6 broadcast address
61 * @mask : network mask
62 */
63 struct lxc_inet6dev {
64 struct in6_addr addr;
65 struct in6_addr bcast;
66 struct in6_addr acast;
67 int prefix;
68 };
69
70 struct lxc_route6 {
71 struct in6_addr addr;
72 };
73
74 struct ifla_vlan {
75 uint flags;
76 uint fmask;
77 ushort vid;
78 ushort pad;
79 };
80
81 /*
82 * Defines a structure to configure a network device
83 * @link : lxc.network.link, name of bridge or host iface to attach if any
84 * @name : lxc.network.name, name of iface on the container side
85 * @pair : lxc.network.pair, name of host-side iface in case of veth etc
86 * @flags : flag of the network device (IFF_UP, ... )
87 * @ipv4 : a list of ipv4 addresses to be set on the network device
88 * @ipv6 : a list of ipv6 addresses to be set on the network device
89 */
90 struct lxc_netdev {
91 int type;
92 int flags;
93 int ifindex;
94 char *link;
95 char *name;
96 char *pair;
97 char *hwaddr;
98 char *mtu;
99 struct ifla_vlan vlan_attr;
100 struct lxc_list ipv4;
101 struct lxc_list ipv6;
102 };
103
104 /*
105 * Defines a generic struct to configure the control group.
106 * It is up to the programmer to specify the right subsystem.
107 * @subsystem : the targetted subsystem
108 * @value : the value to set
109 */
110 struct lxc_cgroup {
111 char *subsystem;
112 char *value;
113 };
114
115 /*
116 * Defines a structure containing a pty information for
117 * virtualizing a tty
118 * @name : the path name of the slave pty side
119 * @master : the file descriptor of the master
120 * @slave : the file descriptor of the slave
121 */
122 struct lxc_pty_info {
123 char name[MAXPATHLEN];
124 int master;
125 int slave;
126 int busy;
127 };
128
129 /*
130 * Defines the number of tty configured and contains the
131 * instanciated ptys
132 * @nbtty = number of configured ttys
133 */
134 struct lxc_tty_info {
135 int nbtty;
136 struct lxc_pty_info *pty_info;
137 };
138
139 /*
140 * Defines the global container configuration
141 * @rootfs : the root directory to run the container
142 * @mount : the list of mount points
143 * @network : the network configuration
144 * @utsname : the container utsname
145 */
146 struct lxc_conf {
147 char *rootfs;
148 char *fstab;
149 int tty;
150 int pts;
151 struct utsname *utsname;
152 struct lxc_list cgroup;
153 struct lxc_list network;
154 struct lxc_list mount_list;
155 struct lxc_tty_info tty_info;
156 char console[MAXPATHLEN];
157 };
158
159 /*
160 * Initialize the lxc configuration structure
161 */
162 extern int lxc_conf_init(struct lxc_conf *conf);
163
164 extern int lxc_create_network(struct lxc_list *networks);
165 extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
166
167 extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
168 extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
169
170 /*
171 * Configure the container from inside
172 */
173
174 struct lxc_handler;
175
176 extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
177
178 extern int conf_has(const char *name, const char *info);
179
180 #define conf_has_fstab(__name) conf_has(__name, "fstab")
181 #define conf_has_rootfs(__name) conf_has(__name, "rootfs")
182 #define conf_has_utsname(__name) conf_has(__name, "utsname")
183 #define conf_has_network(__name) conf_has(__name, "network")
184 #define conf_has_console(__name) conf_has(__name, "console")
185 #define conf_has_cgroup(__name) conf_has(__name, "cgroup")
186 #define conf_has_tty(__name) conf_has(__name, "tty")
187 #define conf_has_pts(__name) conf_has(__name, "pts")
188 #endif