]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/net/link-config.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / udev / net / link-config.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 This file is part of systemd.
6
7 Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 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 License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include "libudev.h"
24
25 #include "condition.h"
26 #include "ethtool-util.h"
27 #include "list.h"
28
29 typedef struct link_config_ctx link_config_ctx;
30 typedef struct link_config link_config;
31
32 typedef enum MACPolicy {
33 MACPOLICY_PERSISTENT,
34 MACPOLICY_RANDOM,
35 MACPOLICY_NONE,
36 _MACPOLICY_MAX,
37 _MACPOLICY_INVALID = -1
38 } MACPolicy;
39
40 typedef enum NamePolicy {
41 NAMEPOLICY_KERNEL,
42 NAMEPOLICY_DATABASE,
43 NAMEPOLICY_ONBOARD,
44 NAMEPOLICY_SLOT,
45 NAMEPOLICY_PATH,
46 NAMEPOLICY_MAC,
47 _NAMEPOLICY_MAX,
48 _NAMEPOLICY_INVALID = -1
49 } NamePolicy;
50
51 struct link_config {
52 char *filename;
53
54 struct ether_addr *match_mac;
55 char **match_path;
56 char **match_driver;
57 char **match_type;
58 char **match_name;
59 Condition *match_host;
60 Condition *match_virt;
61 Condition *match_kernel;
62 Condition *match_arch;
63
64 char *description;
65 struct ether_addr *mac;
66 MACPolicy mac_policy;
67 NamePolicy *name_policy;
68 char *name;
69 char *alias;
70 size_t mtu;
71 size_t speed;
72 Duplex duplex;
73 int autonegotiation;
74 WakeOnLan wol;
75 NetDevPort port;
76 NetDevFeature features[_NET_DEV_FEAT_MAX];
77
78 LIST_FIELDS(link_config, links);
79 };
80
81 int link_config_ctx_new(link_config_ctx **ret);
82 void link_config_ctx_free(link_config_ctx *ctx);
83
84 int link_config_load(link_config_ctx *ctx);
85 bool link_config_should_reload(link_config_ctx *ctx);
86
87 int link_config_get(link_config_ctx *ctx, struct udev_device *device, struct link_config **ret);
88 int link_config_apply(link_config_ctx *ctx, struct link_config *config, struct udev_device *device, const char **name);
89
90 int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret);
91
92 const char *name_policy_to_string(NamePolicy p) _const_;
93 NamePolicy name_policy_from_string(const char *p) _pure_;
94
95 const char *mac_policy_to_string(MACPolicy p) _const_;
96 MACPolicy mac_policy_from_string(const char *p) _pure_;
97
98 /* gperf lookup function */
99 const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
100
101 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);
102 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);