1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 #include "conf-parser.h"
8 #include "ethtool-util.h"
12 typedef struct link_config_ctx link_config_ctx
;
13 typedef struct link_config link_config
;
15 typedef enum MACPolicy
{
20 _MACPOLICY_INVALID
= -1
23 typedef enum NamePolicy
{
31 _NAMEPOLICY_INVALID
= -1
42 Condition
*match_host
;
43 Condition
*match_virt
;
44 Condition
*match_kernel_cmdline
;
45 Condition
*match_kernel_version
;
46 Condition
*match_arch
;
49 struct ether_addr
*mac
;
51 NamePolicy
*name_policy
;
58 uint32_t advertise
[2];
61 int features
[_NET_DEV_FEAT_MAX
];
62 netdev_channels channels
;
64 LIST_FIELDS(link_config
, links
);
67 int link_config_ctx_new(link_config_ctx
**ret
);
68 void link_config_ctx_free(link_config_ctx
*ctx
);
70 int link_config_load(link_config_ctx
*ctx
);
71 bool link_config_should_reload(link_config_ctx
*ctx
);
73 int link_config_get(link_config_ctx
*ctx
, sd_device
*device
, struct link_config
**ret
);
74 int link_config_apply(link_config_ctx
*ctx
, struct link_config
*config
, sd_device
*device
, const char **name
);
75 int link_get_driver(link_config_ctx
*ctx
, sd_device
*device
, char **ret
);
77 const char *name_policy_to_string(NamePolicy p
) _const_
;
78 NamePolicy
name_policy_from_string(const char *p
) _pure_
;
80 const char *mac_policy_to_string(MACPolicy p
) _const_
;
81 MACPolicy
mac_policy_from_string(const char *p
) _pure_
;
83 /* gperf lookup function */
84 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
86 CONFIG_PARSER_PROTOTYPE(config_parse_mac_policy
);
87 CONFIG_PARSER_PROTOTYPE(config_parse_name_policy
);