1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
12 #include "condition.h"
13 #include "ethtool-util.h"
17 typedef struct link_config_ctx link_config_ctx
;
18 typedef struct link_config link_config
;
20 typedef enum MACPolicy
{
25 _MACPOLICY_INVALID
= -1
28 typedef enum NamePolicy
{
36 _NAMEPOLICY_INVALID
= -1
47 Condition
*match_host
;
48 Condition
*match_virt
;
49 Condition
*match_kernel_cmdline
;
50 Condition
*match_kernel_version
;
51 Condition
*match_arch
;
54 struct ether_addr
*mac
;
56 NamePolicy
*name_policy
;
65 NetDevFeature features
[_NET_DEV_FEAT_MAX
];
66 netdev_channels channels
;
68 LIST_FIELDS(link_config
, links
);
71 int link_config_ctx_new(link_config_ctx
**ret
);
72 void link_config_ctx_free(link_config_ctx
*ctx
);
74 int link_config_load(link_config_ctx
*ctx
);
75 bool link_config_should_reload(link_config_ctx
*ctx
);
77 int link_config_get(link_config_ctx
*ctx
, struct udev_device
*device
, struct link_config
**ret
);
78 int link_config_apply(link_config_ctx
*ctx
, struct link_config
*config
, struct udev_device
*device
, const char **name
);
80 int link_get_driver(link_config_ctx
*ctx
, struct udev_device
*device
, char **ret
);
82 const char *name_policy_to_string(NamePolicy p
) _const_
;
83 NamePolicy
name_policy_from_string(const char *p
) _pure_
;
85 const char *mac_policy_to_string(MACPolicy p
) _const_
;
86 MACPolicy
mac_policy_from_string(const char *p
) _pure_
;
88 /* gperf lookup function */
89 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
91 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
);
92 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
);