]> git.ipfire.org Git - thirdparty/systemd.git/blame - 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
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
0ef6f454
LP
2#pragma once
3
af6f0d42
TG
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
07630cea
LP
23#include "libudev.h"
24
134e56dc 25#include "condition.h"
07630cea 26#include "ethtool-util.h"
af6f0d42
TG
27#include "list.h"
28
af6f0d42
TG
29typedef struct link_config_ctx link_config_ctx;
30typedef struct link_config link_config;
31
5fde13d7
TG
32typedef enum MACPolicy {
33 MACPOLICY_PERSISTENT,
34 MACPOLICY_RANDOM,
66d3752e 35 MACPOLICY_NONE,
5fde13d7
TG
36 _MACPOLICY_MAX,
37 _MACPOLICY_INVALID = -1
38} MACPolicy;
39
40typedef enum NamePolicy {
04b67d49 41 NAMEPOLICY_KERNEL,
e51660ae 42 NAMEPOLICY_DATABASE,
5fde13d7
TG
43 NAMEPOLICY_ONBOARD,
44 NAMEPOLICY_SLOT,
45 NAMEPOLICY_PATH,
46 NAMEPOLICY_MAC,
47 _NAMEPOLICY_MAX,
48 _NAMEPOLICY_INVALID = -1
49} NamePolicy;
50
af6f0d42
TG
51struct link_config {
52 char *filename;
53
5fde13d7 54 struct ether_addr *match_mac;
5256e00e
TG
55 char **match_path;
56 char **match_driver;
57 char **match_type;
58 char **match_name;
2cc412b5
TG
59 Condition *match_host;
60 Condition *match_virt;
61 Condition *match_kernel;
edbb03e9 62 Condition *match_arch;
af6f0d42
TG
63
64 char *description;
5fde13d7
TG
65 struct ether_addr *mac;
66 MACPolicy mac_policy;
67 NamePolicy *name_policy;
43b3a5ef 68 char *name;
d2df0d0e 69 char *alias;
dab495dc
TG
70 size_t mtu;
71 size_t speed;
5fde13d7 72 Duplex duplex;
a39f92d3 73 int autonegotiation;
5fde13d7 74 WakeOnLan wol;
593022fa 75 NetDevPort port;
50725d10 76 NetDevFeature features[_NET_DEV_FEAT_MAX];
af6f0d42
TG
77
78 LIST_FIELDS(link_config, links);
79};
80
81int link_config_ctx_new(link_config_ctx **ret);
82void link_config_ctx_free(link_config_ctx *ctx);
83
84int link_config_load(link_config_ctx *ctx);
85bool link_config_should_reload(link_config_ctx *ctx);
86
87int link_config_get(link_config_ctx *ctx, struct udev_device *device, struct link_config **ret);
3e137a1b 88int link_config_apply(link_config_ctx *ctx, struct link_config *config, struct udev_device *device, const char **name);
af6f0d42 89
847a8a5f
TG
90int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret);
91
5fde13d7
TG
92const char *name_policy_to_string(NamePolicy p) _const_;
93NamePolicy name_policy_from_string(const char *p) _pure_;
94
95const char *mac_policy_to_string(MACPolicy p) _const_;
96MACPolicy mac_policy_from_string(const char *p) _pure_;
97
af6f0d42 98/* gperf lookup function */
c9f7b4d3 99const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
5fde13d7 100
71a61510
TG
101int 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);
102int 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);