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"
16 typedef struct link_config_ctx link_config_ctx
;
17 typedef struct link_config link_config
;
19 typedef enum MACPolicy
{
24 _MACPOLICY_INVALID
= -1
27 typedef enum NamePolicy
{
35 _NAMEPOLICY_INVALID
= -1
41 struct ether_addr
*match_mac
;
46 Condition
*match_host
;
47 Condition
*match_virt
;
48 Condition
*match_kernel_cmdline
;
49 Condition
*match_kernel_version
;
50 Condition
*match_arch
;
53 struct ether_addr
*mac
;
55 NamePolicy
*name_policy
;
64 NetDevFeature features
[_NET_DEV_FEAT_MAX
];
66 LIST_FIELDS(link_config
, links
);
69 int link_config_ctx_new(link_config_ctx
**ret
);
70 void link_config_ctx_free(link_config_ctx
*ctx
);
72 int link_config_load(link_config_ctx
*ctx
);
73 bool link_config_should_reload(link_config_ctx
*ctx
);
75 int link_config_get(link_config_ctx
*ctx
, struct udev_device
*device
, struct link_config
**ret
);
76 int link_config_apply(link_config_ctx
*ctx
, struct link_config
*config
, struct udev_device
*device
, const char **name
);
78 int link_get_driver(link_config_ctx
*ctx
, struct udev_device
*device
, char **ret
);
80 const char *name_policy_to_string(NamePolicy p
) _const_
;
81 NamePolicy
name_policy_from_string(const char *p
) _pure_
;
83 const char *mac_policy_to_string(MACPolicy p
) _const_
;
84 MACPolicy
mac_policy_from_string(const char *p
) _pure_
;
86 /* gperf lookup function */
87 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
89 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
);
90 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
);