]>
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> |
0ad19a3f | 28 | |
00b3c2e2 CLG |
29 | #include <lxc/list.h> |
30 | ||
13954cce | 31 | enum { |
24654103 DL |
32 | LXC_NET_EMPTY, |
33 | LXC_NET_VETH, | |
34 | LXC_NET_MACVLAN, | |
35 | LXC_NET_PHYS, | |
36 | LXC_NET_VLAN, | |
37 | LXC_NET_MAXCONFTYPE, | |
0ad19a3f | 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 | }; | |
26c39028 | 73 | |
e892973e DL |
74 | struct ifla_veth { |
75 | char *pair; /* pair name */ | |
76 | }; | |
77 | ||
26c39028 JHS |
78 | struct ifla_vlan { |
79 | uint flags; | |
80 | uint fmask; | |
81 | ushort vid; | |
82 | ushort pad; | |
83 | }; | |
84 | ||
e892973e DL |
85 | struct ifla_macvlan { |
86 | int mode; /* private, vepa, bridge */ | |
87 | }; | |
88 | ||
f6cc1de1 | 89 | union netdev_p { |
e892973e | 90 | struct ifla_veth veth_attr; |
f6cc1de1 | 91 | struct ifla_vlan vlan_attr; |
e892973e | 92 | struct ifla_macvlan macvlan_attr; |
f6cc1de1 JHS |
93 | }; |
94 | ||
0ad19a3f | 95 | /* |
96 | * Defines a structure to configure a network device | |
9d083402 MT |
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 | |
0ad19a3f | 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 { | |
5f4535a3 | 104 | int type; |
0ad19a3f | 105 | int flags; |
82d5ae15 | 106 | int ifindex; |
9d083402 MT |
107 | char *link; |
108 | char *name; | |
0ad19a3f | 109 | char *hwaddr; |
442cbbe6 | 110 | char *mtu; |
f6cc1de1 | 111 | union netdev_p priv; |
0ad19a3f | 112 | struct lxc_list ipv4; |
113 | struct lxc_list ipv6; | |
0ad19a3f | 114 | }; |
115 | ||
116 | /* | |
576f946d | 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 | |
0ad19a3f | 121 | */ |
122 | struct lxc_cgroup { | |
576f946d | 123 | char *subsystem; |
124 | char *value; | |
0ad19a3f | 125 | }; |
126 | ||
b0a33c1e | 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 | ||
63376d7d DL |
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; | |
28a4b0e5 | 160 | char *path; |
63376d7d | 161 | char name[MAXPATHLEN]; |
e0dc0de7 | 162 | struct termios *tios; |
63376d7d DL |
163 | }; |
164 | ||
33fcb7a0 DL |
165 | /* |
166 | * Defines a structure to store the rootfs location, the | |
167 | * optionals pivot_root, rootfs mount paths | |
168 | * @rootfs : a path to the rootfs | |
169 | * @pivot_root : a path to a pivot_root location to be used | |
170 | */ | |
171 | struct lxc_rootfs { | |
172 | char *path; | |
173 | char *pivot; | |
174 | }; | |
175 | ||
571e6ec8 DL |
176 | /* |
177 | * Defines the global container configuration | |
63376d7d DL |
178 | * @rootfs : root directory to run the container |
179 | * @pivotdir : pivotdir path, if not set default will be used | |
180 | * @mount : list of mount points | |
181 | * @tty : numbers of tty | |
182 | * @pts : new pts instance | |
183 | * @mount_list : list of mount point (alternative to fstab file) | |
184 | * @network : network configuration | |
185 | * @utsname : container utsname | |
186 | * @fstab : path to a fstab file format | |
187 | * @caps : list of the capabilities | |
188 | * @tty_info : tty data | |
189 | * @console : console data | |
571e6ec8 DL |
190 | */ |
191 | struct lxc_conf { | |
571e6ec8 DL |
192 | char *fstab; |
193 | int tty; | |
194 | int pts; | |
91480a0f | 195 | int reboot; |
571e6ec8 DL |
196 | struct utsname *utsname; |
197 | struct lxc_list cgroup; | |
5f4535a3 | 198 | struct lxc_list network; |
e7938e9e | 199 | struct lxc_list mount_list; |
81810dd1 | 200 | struct lxc_list caps; |
571e6ec8 | 201 | struct lxc_tty_info tty_info; |
63376d7d | 202 | struct lxc_console console; |
33fcb7a0 | 203 | struct lxc_rootfs rootfs; |
571e6ec8 DL |
204 | }; |
205 | ||
089cd8b8 DL |
206 | /* |
207 | * Initialize the lxc configuration structure | |
208 | */ | |
7b379ab3 | 209 | extern struct lxc_conf *lxc_conf_init(void); |
089cd8b8 | 210 | |
82d5ae15 | 211 | extern int lxc_create_network(struct lxc_list *networks); |
7fef7a06 | 212 | extern void lxc_delete_network(struct lxc_list *networks); |
82d5ae15 | 213 | extern int lxc_assign_network(struct lxc_list *networks, pid_t pid); |
0ad19a3f | 214 | |
5e4a62bf | 215 | extern int lxc_create_tty(const char *name, struct lxc_conf *conf); |
b0a33c1e | 216 | extern void lxc_delete_tty(struct lxc_tty_info *tty_info); |
217 | ||
0ad19a3f | 218 | /* |
219 | * Configure the container from inside | |
220 | */ | |
88d5514d DL |
221 | |
222 | struct lxc_handler; | |
223 | ||
571e6ec8 | 224 | extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf); |
0ad19a3f | 225 | |
0ad19a3f | 226 | #endif |