]>
Commit | Line | Data |
---|---|---|
0b843d35 CB |
1 | /* liblxcapi |
2 | * | |
3 | * Copyright © 2017 Christian Brauner <christian.brauner@ubuntu.com>. | |
4 | * Copyright © 2017 Canonical Ltd. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2, as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; if not, write to the Free Software Foundation, Inc., | |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | */ | |
19 | ||
20 | #ifndef __LXC_CONFILE_UTILS_H | |
21 | #define __LXC_CONFILE_UTILS_H | |
22 | ||
663e9916 CB |
23 | #include <stdbool.h> |
24 | ||
ce2f5ae8 | 25 | #include "conf.h" |
f9373e40 | 26 | #include "confile_utils.h" |
ce2f5ae8 | 27 | |
9b0df30f CB |
28 | #ifndef MACVLAN_MODE_PRIVATE |
29 | #define MACVLAN_MODE_PRIVATE 1 | |
30 | #endif | |
31 | ||
32 | #ifndef MACVLAN_MODE_VEPA | |
33 | #define MACVLAN_MODE_VEPA 2 | |
34 | #endif | |
35 | ||
36 | #ifndef MACVLAN_MODE_BRIDGE | |
37 | #define MACVLAN_MODE_BRIDGE 4 | |
38 | #endif | |
39 | ||
40 | #ifndef MACVLAN_MODE_PASSTHRU | |
41 | #define MACVLAN_MODE_PASSTHRU 8 | |
42 | #endif | |
43 | ||
f9373e40 CB |
44 | #define strprint(str, inlen, ...) \ |
45 | do { \ | |
46 | len = snprintf(str, inlen, ##__VA_ARGS__); \ | |
47 | if (len < 0) { \ | |
48 | SYSERROR("failed to create string"); \ | |
49 | return -1; \ | |
50 | }; \ | |
51 | fulllen += len; \ | |
52 | if (inlen > 0) { \ | |
53 | if (str) \ | |
54 | str += len; \ | |
55 | inlen -= len; \ | |
56 | if (inlen < 0) \ | |
57 | inlen = 0; \ | |
58 | } \ | |
59 | } while (0); | |
60 | ||
0b843d35 CB |
61 | extern int parse_idmaps(const char *idmap, char *type, unsigned long *nsid, |
62 | unsigned long *hostid, unsigned long *range); | |
63 | ||
663e9916 | 64 | extern bool lxc_config_value_empty(const char *value); |
c302b476 CB |
65 | extern struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, |
66 | bool tail); | |
0070b1c4 CB |
67 | extern struct lxc_netdev * |
68 | lxc_get_netdev_by_idx(struct lxc_conf *conf, unsigned int idx, bool allocate); | |
1ed6ba91 | 69 | extern void lxc_log_configured_netdevs(const struct lxc_conf *conf); |
519df1c1 | 70 | extern bool lxc_remove_nic_by_idx(struct lxc_conf *conf, unsigned int idx); |
c302b476 | 71 | extern void lxc_free_networks(struct lxc_list *networks); |
9b0df30f CB |
72 | extern int lxc_macvlan_mode_to_flag(int *mode, const char *value); |
73 | extern char *lxc_macvlan_flag_to_mode(int mode); | |
663e9916 | 74 | |
f9373e40 CB |
75 | extern int set_config_string_item(char **conf_item, const char *value); |
76 | extern int set_config_string_item_max(char **conf_item, const char *value, | |
77 | size_t max); | |
78 | extern int set_config_path_item(char **conf_item, const char *value); | |
79 | extern int config_ip_prefix(struct in_addr *addr); | |
de4855a8 | 80 | extern int network_ifname(char *valuep, const char *value); |
f9373e40 | 81 | extern int rand_complete_hwaddr(char *hwaddr); |
ce4be612 | 82 | extern bool lxc_config_net_hwaddr(const char *line); |
f9373e40 CB |
83 | extern void update_hwaddr(const char *line); |
84 | extern bool new_hwaddr(char *hwaddr); | |
953fe44f CB |
85 | extern int lxc_get_conf_str(char *retv, int inlen, const char *value); |
86 | extern int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen, int v); | |
2ea479c9 | 87 | extern int lxc_get_conf_uint64(struct lxc_conf *c, char *retv, int inlen, uint64_t v); |
71460831 | 88 | extern bool parse_limit_value(const char **value, rlim_t *res); |
28d9e29e CB |
89 | extern int lxc_inherit_namespace(const char *lxcname_or_pid, |
90 | const char *lxcpath, const char *namespace); | |
2ea479c9 | 91 | |
0b843d35 | 92 | #endif /* __LXC_CONFILE_UTILS_H */ |