]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/conf.h
add lxc.network.script.up configuration hook
[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 #include <start.h> /* for lxc_handler */
32
33 enum {
34 LXC_NET_EMPTY,
35 LXC_NET_VETH,
36 LXC_NET_MACVLAN,
37 LXC_NET_PHYS,
38 LXC_NET_VLAN,
39 LXC_NET_MAXCONFTYPE,
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 */
48 struct lxc_inetdev {
49 struct in_addr addr;
50 struct in_addr bcast;
51 int prefix;
52 };
53
54 struct 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 */
65 struct lxc_inet6dev {
66 struct in6_addr addr;
67 struct in6_addr mcast;
68 struct in6_addr acast;
69 int prefix;
70 };
71
72 struct lxc_route6 {
73 struct in6_addr addr;
74 };
75
76 struct ifla_veth {
77 char *pair; /* pair name */
78 };
79
80 struct ifla_vlan {
81 uint flags;
82 uint fmask;
83 ushort vid;
84 ushort pad;
85 };
86
87 struct ifla_macvlan {
88 int mode; /* private, vepa, bridge */
89 };
90
91 union netdev_p {
92 struct ifla_veth veth_attr;
93 struct ifla_vlan vlan_attr;
94 struct ifla_macvlan macvlan_attr;
95 };
96
97 /*
98 * Defines a structure to configure a network device
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
105 */
106 struct lxc_netdev {
107 int type;
108 int flags;
109 int ifindex;
110 char *link;
111 char *name;
112 char *hwaddr;
113 char *mtu;
114 union netdev_p priv;
115 struct lxc_list ipv4;
116 struct lxc_list ipv6;
117 char *upscript;
118 };
119
120 /*
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
125 */
126 struct lxc_cgroup {
127 char *subsystem;
128 char *value;
129 };
130
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 */
138 struct 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 */
150 struct lxc_tty_info {
151 int nbtty;
152 struct lxc_pty_info *pty_info;
153 };
154
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 */
160 struct lxc_console {
161 int slave;
162 int master;
163 int peer;
164 char *path;
165 char name[MAXPATHLEN];
166 struct termios *tios;
167 };
168
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 */
175 struct lxc_rootfs {
176 char *path;
177 char *mount;
178 char *pivot;
179 };
180
181 /*
182 * Defines the global container configuration
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
195 */
196 struct lxc_conf {
197 char *fstab;
198 int tty;
199 int pts;
200 int reboot;
201 int personality;
202 struct utsname *utsname;
203 struct lxc_list cgroup;
204 struct lxc_list network;
205 struct lxc_list mount_list;
206 struct lxc_list caps;
207 struct lxc_tty_info tty_info;
208 struct lxc_console console;
209 struct lxc_rootfs rootfs;
210 };
211
212 /*
213 * Initialize the lxc configuration structure
214 */
215 extern struct lxc_conf *lxc_conf_init(void);
216
217 extern int lxc_create_network(struct lxc_handler *handler);
218 extern void lxc_delete_network(struct lxc_list *networks);
219 extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
220
221 extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
222 extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
223
224 /*
225 * Configure the container from inside
226 */
227
228 extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
229 #endif