]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/conf.h
lxc: avoid memory corruption on ppc and s390 V4
[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_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 global container configuration
153 * @rootfs : the root directory to run the container
154 * @mount : the list of mount points
155 * @network : the network configuration
156 * @utsname : the container utsname
157 */
158 struct lxc_conf {
159 char *rootfs;
160 char *fstab;
161 int tty;
162 int pts;
163 struct utsname *utsname;
164 struct lxc_list cgroup;
165 struct lxc_list network;
166 struct lxc_list mount_list;
167 struct lxc_tty_info tty_info;
168 char console[MAXPATHLEN];
169 };
170
171 /*
172 * Initialize the lxc configuration structure
173 */
174 extern struct lxc_conf *lxc_conf_init(void);
175
176 extern int lxc_create_network(struct lxc_list *networks);
177 extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
178
179 extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
180 extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
181
182 /*
183 * Configure the container from inside
184 */
185
186 struct lxc_handler;
187
188 extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
189
190 extern int conf_has(const char *name, const char *info);
191
192 #define conf_has_fstab(__name) conf_has(__name, "fstab")
193 #define conf_has_rootfs(__name) conf_has(__name, "rootfs")
194 #define conf_has_utsname(__name) conf_has(__name, "utsname")
195 #define conf_has_network(__name) conf_has(__name, "network")
196 #define conf_has_console(__name) conf_has(__name, "console")
197 #define conf_has_cgroup(__name) conf_has(__name, "cgroup")
198 #define conf_has_tty(__name) conf_has(__name, "tty")
199 #define conf_has_pts(__name) conf_has(__name, "pts")
200 #endif