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
];
65 netdev_channels channels
;
67 LIST_FIELDS(link_config
, links
);
70 int link_config_ctx_new(link_config_ctx
**ret
);
71 void link_config_ctx_free(link_config_ctx
*ctx
);
73 int link_config_load(link_config_ctx
*ctx
);
74 bool link_config_should_reload(link_config_ctx
*ctx
);
76 int link_config_get(link_config_ctx
*ctx
, struct udev_device
*device
, struct link_config
**ret
);
77 int link_config_apply(link_config_ctx
*ctx
, struct link_config
*config
, struct udev_device
*device
, const char **name
);
79 int link_get_driver(link_config_ctx
*ctx
, struct udev_device
*device
, char **ret
);
81 const char *name_policy_to_string(NamePolicy p
) _const_
;
82 NamePolicy
name_policy_from_string(const char *p
) _pure_
;
84 const char *mac_policy_to_string(MACPolicy p
) _const_
;
85 MACPolicy
mac_policy_from_string(const char *p
) _pure_
;
87 /* gperf lookup function */
88 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
90 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
);
91 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
);