]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/udev/net/link-config.h
Merge pull request #21838 from lnussel/logind-refactor
[thirdparty/systemd.git] / src / udev / net / link-config.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
0ef6f454
LP
2#pragma once
3
e5eadf53 4#include "sd-device.h"
751dcd8d 5#include "sd-netlink.h"
07630cea 6
134e56dc 7#include "condition.h"
538f15cf 8#include "conf-parser.h"
07630cea 9#include "ethtool-util.h"
bd29dfef 10#include "hashmap.h"
af6f0d42 11#include "list.h"
5722fb89 12#include "net-condition.h"
ff516b43 13#include "netif-naming-scheme.h"
af6f0d42 14
afca7ac1 15typedef struct LinkConfigContext LinkConfigContext;
ce01c07f 16typedef struct LinkConfig LinkConfig;
af6f0d42 17
54ed9f88
ZJS
18typedef enum MACAddressPolicy {
19 MAC_ADDRESS_POLICY_PERSISTENT,
20 MAC_ADDRESS_POLICY_RANDOM,
21 MAC_ADDRESS_POLICY_NONE,
22 _MAC_ADDRESS_POLICY_MAX,
2d93c20e 23 _MAC_ADDRESS_POLICY_INVALID = -EINVAL,
54ed9f88 24} MACAddressPolicy;
5fde13d7 25
613701a4
YW
26typedef struct Link {
27 int ifindex;
28 const char *ifname;
29 const char *new_name;
30
31 LinkConfig *config;
32 sd_device *device;
33 sd_device_action_t action;
34
35 char *driver;
36 uint16_t iftype;
37 uint32_t flags;
38 struct hw_addr_data hw_addr;
39 struct hw_addr_data permanent_hw_addr;
40 unsigned name_assign_type;
41 unsigned addr_assign_type;
42} Link;
43
ce01c07f 44struct LinkConfig {
af6f0d42
TG
45 char *filename;
46
5722fb89 47 NetMatch match;
1beabe08 48 LIST_HEAD(Condition, conditions);
af6f0d42
TG
49
50 char *description;
9e2b7763 51 struct hw_addr_data hw_addr;
54ed9f88 52 MACAddressPolicy mac_address_policy;
5fde13d7 53 NamePolicy *name_policy;
ef1d2c07 54 NamePolicy *alternative_names_policy;
43b3a5ef 55 char *name;
a5053a15 56 char **alternative_names;
d2df0d0e 57 char *alias;
face9fcc
YW
58 uint32_t txqueues;
59 uint32_t rxqueues;
ef4a91a7 60 uint32_t txqueuelen;
4e964aa0 61 uint32_t mtu;
1e270127
SS
62 uint32_t gso_max_segments;
63 size_t gso_max_size;
50299121 64 uint64_t speed;
5fde13d7 65 Duplex duplex;
a39f92d3 66 int autonegotiation;
5c2316c6 67 uint32_t advertise[N_ADVERTISE];
c50404ae 68 uint32_t wol;
d3867133
YW
69 char *wol_password_file;
70 uint8_t *wol_password;
593022fa 71 NetDevPort port;
cc2ff878 72 int features[_NET_DEV_FEAT_MAX];
5f945202 73 netdev_channels channels;
224ded67 74 netdev_ring_param ring;
a34811e4
YW
75 int rx_flow_control;
76 int tx_flow_control;
77 int autoneg_flow_control;
6c35ea5e 78 netdev_coalesce_param coalesce;
af6f0d42 79
41ce9d76 80 uint32_t sr_iov_num_vfs;
bd29dfef
YW
81 OrderedHashmap *sr_iov_by_section;
82
418c02c3 83 LIST_FIELDS(LinkConfig, configs);
af6f0d42
TG
84};
85
afca7ac1
YW
86int link_config_ctx_new(LinkConfigContext **ret);
87LinkConfigContext* link_config_ctx_free(LinkConfigContext *ctx);
88DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfigContext*, link_config_ctx_free);
af6f0d42 89
afca7ac1
YW
90int link_load_one(LinkConfigContext *ctx, const char *filename);
91int link_config_load(LinkConfigContext *ctx);
92bool link_config_should_reload(LinkConfigContext *ctx);
af6f0d42 93
613701a4
YW
94int link_new(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, Link **ret);
95Link *link_free(Link *link);
96DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
97
98int link_get_config(LinkConfigContext *ctx, Link *link);
99int link_apply_config(LinkConfigContext *ctx, sd_netlink **rtnl, Link *link);
847a8a5f 100
54ed9f88
ZJS
101const char *mac_address_policy_to_string(MACAddressPolicy p) _const_;
102MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
5fde13d7 103
af6f0d42 104/* gperf lookup function */
c9f7b4d3 105const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
5fde13d7 106
fc27088a 107CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
face9fcc 108CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues);
ef4a91a7 109CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen);
d3867133 110CONFIG_PARSER_PROTOTYPE(config_parse_wol_password);
54ed9f88 111CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
538f15cf 112CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
ef1d2c07 113CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy);