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