]>
Commit | Line | Data |
---|---|---|
af6f0d42 TG |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright (C) 2013 Tom Gundersen <teg@jklm.no> | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #pragma once | |
23 | ||
07630cea LP |
24 | #include "libudev.h" |
25 | ||
134e56dc | 26 | #include "condition.h" |
07630cea | 27 | #include "ethtool-util.h" |
af6f0d42 TG |
28 | #include "list.h" |
29 | ||
af6f0d42 TG |
30 | typedef struct link_config_ctx link_config_ctx; |
31 | typedef struct link_config link_config; | |
32 | ||
5fde13d7 TG |
33 | typedef enum MACPolicy { |
34 | MACPOLICY_PERSISTENT, | |
35 | MACPOLICY_RANDOM, | |
66d3752e | 36 | MACPOLICY_NONE, |
5fde13d7 TG |
37 | _MACPOLICY_MAX, |
38 | _MACPOLICY_INVALID = -1 | |
39 | } MACPolicy; | |
40 | ||
41 | typedef enum NamePolicy { | |
04b67d49 | 42 | NAMEPOLICY_KERNEL, |
e51660ae | 43 | NAMEPOLICY_DATABASE, |
5fde13d7 TG |
44 | NAMEPOLICY_ONBOARD, |
45 | NAMEPOLICY_SLOT, | |
46 | NAMEPOLICY_PATH, | |
47 | NAMEPOLICY_MAC, | |
48 | _NAMEPOLICY_MAX, | |
49 | _NAMEPOLICY_INVALID = -1 | |
50 | } NamePolicy; | |
51 | ||
af6f0d42 TG |
52 | struct link_config { |
53 | char *filename; | |
54 | ||
5fde13d7 | 55 | struct ether_addr *match_mac; |
5256e00e TG |
56 | char **match_path; |
57 | char **match_driver; | |
58 | char **match_type; | |
59 | char **match_name; | |
2cc412b5 TG |
60 | Condition *match_host; |
61 | Condition *match_virt; | |
62 | Condition *match_kernel; | |
edbb03e9 | 63 | Condition *match_arch; |
af6f0d42 TG |
64 | |
65 | char *description; | |
5fde13d7 TG |
66 | struct ether_addr *mac; |
67 | MACPolicy mac_policy; | |
68 | NamePolicy *name_policy; | |
43b3a5ef | 69 | char *name; |
d2df0d0e | 70 | char *alias; |
dab495dc TG |
71 | size_t mtu; |
72 | size_t speed; | |
5fde13d7 TG |
73 | Duplex duplex; |
74 | WakeOnLan wol; | |
af6f0d42 TG |
75 | |
76 | LIST_FIELDS(link_config, links); | |
77 | }; | |
78 | ||
79 | int link_config_ctx_new(link_config_ctx **ret); | |
80 | void link_config_ctx_free(link_config_ctx *ctx); | |
81 | ||
82 | int link_config_load(link_config_ctx *ctx); | |
83 | bool link_config_should_reload(link_config_ctx *ctx); | |
84 | ||
85 | int link_config_get(link_config_ctx *ctx, struct udev_device *device, struct link_config **ret); | |
3e137a1b | 86 | int link_config_apply(link_config_ctx *ctx, struct link_config *config, struct udev_device *device, const char **name); |
af6f0d42 | 87 | |
847a8a5f TG |
88 | int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret); |
89 | ||
5fde13d7 TG |
90 | const char *name_policy_to_string(NamePolicy p) _const_; |
91 | NamePolicy name_policy_from_string(const char *p) _pure_; | |
92 | ||
93 | const char *mac_policy_to_string(MACPolicy p) _const_; | |
94 | MACPolicy mac_policy_from_string(const char *p) _pure_; | |
95 | ||
af6f0d42 TG |
96 | /* gperf lookup function */ |
97 | const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, unsigned length); | |
5fde13d7 | 98 | |
71a61510 TG |
99 | int config_parse_mac_policy(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |
100 | int config_parse_name_policy(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |