]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/conf.h
.gateway configuration
[mirror_lxc.git] / src / lxc / conf.h
CommitLineData
0ad19a3f 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>
b0a33c1e 27#include <sys/param.h>
0ad19a3f 28
00b3c2e2
CLG
29#include <lxc/list.h>
30
43de51b7 31#include <lxc/start.h> /* for lxc_handler */
e3b4c4c4 32
13954cce 33enum {
24654103
DL
34 LXC_NET_EMPTY,
35 LXC_NET_VETH,
36 LXC_NET_MACVLAN,
37 LXC_NET_PHYS,
38 LXC_NET_VLAN,
39 LXC_NET_MAXCONFTYPE,
0ad19a3f 40};
41
42/*
43 * Defines the structure to configure an ipv4 address
44 * @address : ipv4 address
45 * @broadcast : ipv4 broadcast address
46 * @mask : network mask
47 */
48struct lxc_inetdev {
49 struct in_addr addr;
50 struct in_addr bcast;
51 int prefix;
52};
53
54struct lxc_route {
55 struct in_addr addr;
56};
57
58/*
59 * Defines the structure to configure an ipv6 address
60 * @flags : set the address up
61 * @address : ipv6 address
62 * @broadcast : ipv6 broadcast address
63 * @mask : network mask
64 */
65struct lxc_inet6dev {
66 struct in6_addr addr;
0093bb8c 67 struct in6_addr mcast;
0ad19a3f 68 struct in6_addr acast;
69 int prefix;
70};
71
72struct lxc_route6 {
73 struct in6_addr addr;
74};
26c39028 75
e892973e
DL
76struct ifla_veth {
77 char *pair; /* pair name */
78};
79
26c39028
JHS
80struct ifla_vlan {
81 uint flags;
82 uint fmask;
83 ushort vid;
84 ushort pad;
85};
86
e892973e
DL
87struct ifla_macvlan {
88 int mode; /* private, vepa, bridge */
89};
90
f6cc1de1 91union netdev_p {
e892973e 92 struct ifla_veth veth_attr;
f6cc1de1 93 struct ifla_vlan vlan_attr;
e892973e 94 struct ifla_macvlan macvlan_attr;
f6cc1de1
JHS
95};
96
0ad19a3f 97/*
98 * Defines a structure to configure a network device
e3b4c4c4
ST
99 * @link : lxc.network.link, name of bridge or host iface to attach if any
100 * @name : lxc.network.name, name of iface on the container side
101 * @flags : flag of the network device (IFF_UP, ... )
102 * @ipv4 : a list of ipv4 addresses to be set on the network device
103 * @ipv6 : a list of ipv6 addresses to be set on the network device
104 * @upscript : a script filename to be executed during interface configuration
0ad19a3f 105 */
106struct lxc_netdev {
5f4535a3 107 int type;
0ad19a3f 108 int flags;
82d5ae15 109 int ifindex;
9d083402
MT
110 char *link;
111 char *name;
0ad19a3f 112 char *hwaddr;
442cbbe6 113 char *mtu;
f6cc1de1 114 union netdev_p priv;
0ad19a3f 115 struct lxc_list ipv4;
116 struct lxc_list ipv6;
f8fee0e2
MK
117 struct in_addr *ipv4_gateway;
118 struct in6_addr *ipv6_gateway;
e3b4c4c4 119 char *upscript;
0ad19a3f 120};
121
122/*
576f946d 123 * Defines a generic struct to configure the control group.
124 * It is up to the programmer to specify the right subsystem.
125 * @subsystem : the targetted subsystem
126 * @value : the value to set
0ad19a3f 127 */
128struct lxc_cgroup {
576f946d 129 char *subsystem;
130 char *value;
0ad19a3f 131};
132
b0a33c1e 133/*
134 * Defines a structure containing a pty information for
135 * virtualizing a tty
136 * @name : the path name of the slave pty side
137 * @master : the file descriptor of the master
138 * @slave : the file descriptor of the slave
139 */
140struct lxc_pty_info {
141 char name[MAXPATHLEN];
142 int master;
143 int slave;
144 int busy;
145};
146
147/*
148 * Defines the number of tty configured and contains the
149 * instanciated ptys
150 * @nbtty = number of configured ttys
151 */
152struct lxc_tty_info {
153 int nbtty;
154 struct lxc_pty_info *pty_info;
155};
156
63376d7d
DL
157/*
158 * Defines the structure to store the console information
159 * @peer : the file descriptor put/get console traffic
160 * @name : the file name of the slave pty
161 */
162struct lxc_console {
163 int slave;
164 int master;
165 int peer;
28a4b0e5 166 char *path;
63376d7d 167 char name[MAXPATHLEN];
e0dc0de7 168 struct termios *tios;
63376d7d
DL
169};
170
33fcb7a0
DL
171/*
172 * Defines a structure to store the rootfs location, the
173 * optionals pivot_root, rootfs mount paths
174 * @rootfs : a path to the rootfs
175 * @pivot_root : a path to a pivot_root location to be used
176 */
177struct lxc_rootfs {
178 char *path;
23b7ea69 179 char *mount;
33fcb7a0
DL
180 char *pivot;
181};
182
571e6ec8
DL
183/*
184 * Defines the global container configuration
63376d7d
DL
185 * @rootfs : root directory to run the container
186 * @pivotdir : pivotdir path, if not set default will be used
187 * @mount : list of mount points
188 * @tty : numbers of tty
189 * @pts : new pts instance
190 * @mount_list : list of mount point (alternative to fstab file)
191 * @network : network configuration
192 * @utsname : container utsname
193 * @fstab : path to a fstab file format
194 * @caps : list of the capabilities
195 * @tty_info : tty data
196 * @console : console data
571e6ec8
DL
197 */
198struct lxc_conf {
571e6ec8
DL
199 char *fstab;
200 int tty;
201 int pts;
91480a0f 202 int reboot;
cccc74b5 203 int personality;
571e6ec8
DL
204 struct utsname *utsname;
205 struct lxc_list cgroup;
5f4535a3 206 struct lxc_list network;
e7938e9e 207 struct lxc_list mount_list;
81810dd1 208 struct lxc_list caps;
571e6ec8 209 struct lxc_tty_info tty_info;
63376d7d 210 struct lxc_console console;
33fcb7a0 211 struct lxc_rootfs rootfs;
571e6ec8
DL
212};
213
089cd8b8
DL
214/*
215 * Initialize the lxc configuration structure
216 */
7b379ab3 217extern struct lxc_conf *lxc_conf_init(void);
089cd8b8 218
e3b4c4c4 219extern int lxc_create_network(struct lxc_handler *handler);
7fef7a06 220extern void lxc_delete_network(struct lxc_list *networks);
82d5ae15 221extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
0ad19a3f 222
5e4a62bf 223extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
b0a33c1e 224extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
225
0ad19a3f 226/*
227 * Configure the container from inside
228 */
88d5514d 229
571e6ec8 230extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
0ad19a3f 231#endif