]> git.proxmox.com Git - systemd.git/blame - src/udev/net/link-config.h
Imported Upstream version 229
[systemd.git] / src / udev / net / link-config.h
CommitLineData
60f067b4
JS
1/***
2 This file is part of systemd.
3
4 Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
5
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18***/
19
20#pragma once
21
db2df898
MP
22#include "libudev.h"
23
f47781d8 24#include "condition.h"
db2df898 25#include "ethtool-util.h"
60f067b4
JS
26#include "list.h"
27
28typedef struct link_config_ctx link_config_ctx;
29typedef struct link_config link_config;
30
31typedef enum MACPolicy {
32 MACPOLICY_PERSISTENT,
33 MACPOLICY_RANDOM,
6300502b 34 MACPOLICY_NONE,
60f067b4
JS
35 _MACPOLICY_MAX,
36 _MACPOLICY_INVALID = -1
37} MACPolicy;
38
39typedef enum NamePolicy {
5eef597e 40 NAMEPOLICY_KERNEL,
60f067b4
JS
41 NAMEPOLICY_DATABASE,
42 NAMEPOLICY_ONBOARD,
43 NAMEPOLICY_SLOT,
44 NAMEPOLICY_PATH,
45 NAMEPOLICY_MAC,
46 _NAMEPOLICY_MAX,
47 _NAMEPOLICY_INVALID = -1
48} NamePolicy;
49
50struct link_config {
51 char *filename;
52
53 struct ether_addr *match_mac;
e735f4d4
MP
54 char **match_path;
55 char **match_driver;
56 char **match_type;
57 char **match_name;
60f067b4
JS
58 Condition *match_host;
59 Condition *match_virt;
60 Condition *match_kernel;
61 Condition *match_arch;
62
63 char *description;
64 struct ether_addr *mac;
65 MACPolicy mac_policy;
66 NamePolicy *name_policy;
67 char *name;
68 char *alias;
e3bff60a
MP
69 size_t mtu;
70 size_t speed;
60f067b4
JS
71 Duplex duplex;
72 WakeOnLan wol;
73
74 LIST_FIELDS(link_config, links);
75};
76
77int link_config_ctx_new(link_config_ctx **ret);
78void link_config_ctx_free(link_config_ctx *ctx);
79
80int link_config_load(link_config_ctx *ctx);
81bool link_config_should_reload(link_config_ctx *ctx);
82
83int link_config_get(link_config_ctx *ctx, struct udev_device *device, struct link_config **ret);
84int link_config_apply(link_config_ctx *ctx, struct link_config *config, struct udev_device *device, const char **name);
85
86int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret);
87
88const char *name_policy_to_string(NamePolicy p) _const_;
89NamePolicy name_policy_from_string(const char *p) _pure_;
90
91const char *mac_policy_to_string(MACPolicy p) _const_;
92MACPolicy mac_policy_from_string(const char *p) _pure_;
93
94/* gperf lookup function */
95const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, unsigned length);
96
97int 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);
98int 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);