]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/conf.h
add lxc.network.script.up configuration hook
[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
e3b4c4c4
ST
31#include <start.h> /* for lxc_handler */
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;
e3b4c4c4 117 char *upscript;
0ad19a3f 118};
119
120/*
576f946d 121 * Defines a generic struct to configure the control group.
122 * It is up to the programmer to specify the right subsystem.
123 * @subsystem : the targetted subsystem
124 * @value : the value to set
0ad19a3f 125 */
126struct lxc_cgroup {
576f946d 127 char *subsystem;
128 char *value;
0ad19a3f 129};
130
b0a33c1e 131/*
132 * Defines a structure containing a pty information for
133 * virtualizing a tty
134 * @name : the path name of the slave pty side
135 * @master : the file descriptor of the master
136 * @slave : the file descriptor of the slave
137 */
138struct lxc_pty_info {
139 char name[MAXPATHLEN];
140 int master;
141 int slave;
142 int busy;
143};
144
145/*
146 * Defines the number of tty configured and contains the
147 * instanciated ptys
148 * @nbtty = number of configured ttys
149 */
150struct lxc_tty_info {
151 int nbtty;
152 struct lxc_pty_info *pty_info;
153};
154
63376d7d
DL
155/*
156 * Defines the structure to store the console information
157 * @peer : the file descriptor put/get console traffic
158 * @name : the file name of the slave pty
159 */
160struct lxc_console {
161 int slave;
162 int master;
163 int peer;
28a4b0e5 164 char *path;
63376d7d 165 char name[MAXPATHLEN];
e0dc0de7 166 struct termios *tios;
63376d7d
DL
167};
168
33fcb7a0
DL
169/*
170 * Defines a structure to store the rootfs location, the
171 * optionals pivot_root, rootfs mount paths
172 * @rootfs : a path to the rootfs
173 * @pivot_root : a path to a pivot_root location to be used
174 */
175struct lxc_rootfs {
176 char *path;
23b7ea69 177 char *mount;
33fcb7a0
DL
178 char *pivot;
179};
180
571e6ec8
DL
181/*
182 * Defines the global container configuration
63376d7d
DL
183 * @rootfs : root directory to run the container
184 * @pivotdir : pivotdir path, if not set default will be used
185 * @mount : list of mount points
186 * @tty : numbers of tty
187 * @pts : new pts instance
188 * @mount_list : list of mount point (alternative to fstab file)
189 * @network : network configuration
190 * @utsname : container utsname
191 * @fstab : path to a fstab file format
192 * @caps : list of the capabilities
193 * @tty_info : tty data
194 * @console : console data
571e6ec8
DL
195 */
196struct lxc_conf {
571e6ec8
DL
197 char *fstab;
198 int tty;
199 int pts;
91480a0f 200 int reboot;
cccc74b5 201 int personality;
571e6ec8
DL
202 struct utsname *utsname;
203 struct lxc_list cgroup;
5f4535a3 204 struct lxc_list network;
e7938e9e 205 struct lxc_list mount_list;
81810dd1 206 struct lxc_list caps;
571e6ec8 207 struct lxc_tty_info tty_info;
63376d7d 208 struct lxc_console console;
33fcb7a0 209 struct lxc_rootfs rootfs;
571e6ec8
DL
210};
211
089cd8b8
DL
212/*
213 * Initialize the lxc configuration structure
214 */
7b379ab3 215extern struct lxc_conf *lxc_conf_init(void);
089cd8b8 216
e3b4c4c4 217extern int lxc_create_network(struct lxc_handler *handler);
7fef7a06 218extern void lxc_delete_network(struct lxc_list *networks);
82d5ae15 219extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
0ad19a3f 220
5e4a62bf 221extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
b0a33c1e 222extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
223
0ad19a3f 224/*
225 * Configure the container from inside
226 */
88d5514d 227
571e6ec8 228extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
0ad19a3f 229#endif