]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/conf.h
open the console later
[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 LXC_NET_EMPTY,
33 LXC_NET_VETH,
34 LXC_NET_MACVLAN,
35 LXC_NET_PHYS,
36 LXC_NET_VLAN,
37 LXC_NET_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_veth {
75 char *pair; /* pair name */
76 };
77
78 struct ifla_vlan {
79 uint flags;
80 uint fmask;
81 ushort vid;
82 ushort pad;
83 };
84
85 struct ifla_macvlan {
86 int mode; /* private, vepa, bridge */
87 };
88
89 union netdev_p {
90 struct ifla_veth veth_attr;
91 struct ifla_vlan vlan_attr;
92 struct ifla_macvlan macvlan_attr;
93 };
94
95 /*
96 * Defines a structure to configure a network device
97 * @link : lxc.network.link, name of bridge or host iface to attach if any
98 * @name : lxc.network.name, name of iface on the container side
99 * @flags : flag of the network device (IFF_UP, ... )
100 * @ipv4 : a list of ipv4 addresses to be set on the network device
101 * @ipv6 : a list of ipv6 addresses to be set on the network device
102 */
103 struct lxc_netdev {
104 int type;
105 int flags;
106 int ifindex;
107 char *link;
108 char *name;
109 char *hwaddr;
110 char *mtu;
111 union netdev_p priv;
112 struct lxc_list ipv4;
113 struct lxc_list ipv6;
114 };
115
116 /*
117 * Defines a generic struct to configure the control group.
118 * It is up to the programmer to specify the right subsystem.
119 * @subsystem : the targetted subsystem
120 * @value : the value to set
121 */
122 struct lxc_cgroup {
123 char *subsystem;
124 char *value;
125 };
126
127 /*
128 * Defines a structure containing a pty information for
129 * virtualizing a tty
130 * @name : the path name of the slave pty side
131 * @master : the file descriptor of the master
132 * @slave : the file descriptor of the slave
133 */
134 struct lxc_pty_info {
135 char name[MAXPATHLEN];
136 int master;
137 int slave;
138 int busy;
139 };
140
141 /*
142 * Defines the number of tty configured and contains the
143 * instanciated ptys
144 * @nbtty = number of configured ttys
145 */
146 struct lxc_tty_info {
147 int nbtty;
148 struct lxc_pty_info *pty_info;
149 };
150
151 /*
152 * Defines the structure to store the console information
153 * @peer : the file descriptor put/get console traffic
154 * @name : the file name of the slave pty
155 */
156 struct lxc_console {
157 int slave;
158 int master;
159 int peer;
160 char *path;
161 char name[MAXPATHLEN];
162 struct termios *tios;
163 };
164
165 /*
166 * Defines the global container configuration
167 * @rootfs : root directory to run the container
168 * @pivotdir : pivotdir path, if not set default will be used
169 * @mount : list of mount points
170 * @tty : numbers of tty
171 * @pts : new pts instance
172 * @mount_list : list of mount point (alternative to fstab file)
173 * @network : network configuration
174 * @utsname : container utsname
175 * @fstab : path to a fstab file format
176 * @caps : list of the capabilities
177 * @tty_info : tty data
178 * @console : console data
179 */
180 struct lxc_conf {
181 char *rootfs;
182 char *pivotdir;
183 char *fstab;
184 int tty;
185 int pts;
186 struct utsname *utsname;
187 struct lxc_list cgroup;
188 struct lxc_list network;
189 struct lxc_list mount_list;
190 struct lxc_list caps;
191 struct lxc_tty_info tty_info;
192 struct lxc_console console;
193 };
194
195 /*
196 * Initialize the lxc configuration structure
197 */
198 extern struct lxc_conf *lxc_conf_init(void);
199
200 extern int lxc_create_network(struct lxc_list *networks);
201 extern void lxc_delete_network(struct lxc_list *networks);
202 extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
203
204 extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
205 extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
206
207 /*
208 * Configure the container from inside
209 */
210
211 struct lxc_handler;
212
213 extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
214
215 #endif